Example usage for android.app Notification setLatestEventInfo

List of usage examples for android.app Notification setLatestEventInfo

Introduction

In this page you can find the example usage for android.app Notification setLatestEventInfo.

Prototype

@Deprecated
public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText,
        PendingIntent contentIntent) 

Source Link

Document

Sets the #contentView field to be a view with the standard "Latest Event" layout.

Usage

From source file:com.tingtingapps.securesms.service.KeyCachingService.java

private void foregroundServiceLegacy() {
    Notification notification = new Notification(com.tingtingapps.securesms.R.drawable.icon_cached,
            getString(com.tingtingapps.securesms.R.string.KeyCachingService_textsecure_passphrase_cached),
            System.currentTimeMillis());
    notification.setLatestEventInfo(getApplicationContext(),
            getString(com.tingtingapps.securesms.R.string.KeyCachingService_passphrase_cached),
            getString(com.tingtingapps.securesms.R.string.KeyCachingService_textsecure_passphrase_cached),
            buildLaunchIntent());//from  w w  w.  ja  v  a2s . c o m
    notification.tickerText = null;

    stopForeground(true);
    startForeground(SERVICE_RUNNING_ID, notification);
}

From source file:com.example.ramap.MainActivity.java

@SuppressWarnings("deprecation")
private void Notify(String notificationTitle, String notificationMessage) {
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    @SuppressWarnings("deprecation")
    Notification notification = new Notification(R.drawable.ic_check_in, "New Check In",
            System.currentTimeMillis());

    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.setLatestEventInfo(MainActivity.this, notificationTitle, notificationMessage, pendingIntent);
    notificationManager.notify(9999, notification);
}

From source file:com.github.play.app.StatusService.java

@SuppressWarnings("deprecation")
private Notification createNotification(final Context context, final Song song, final PendingIntent intent) {
    Notification notification = new Notification();
    notification.icon = drawable.notification;
    notification.flags |= FLAG_ONGOING_EVENT;
    notification.tickerText = getTickerText(song);
    if (SDK_INT >= HONEYCOMB)
        notification.largeIcon = SongArtWrapper.getCachedArt(context, song);
    notification.setLatestEventInfo(context, song.artist, getContentText(song), intent);
    return notification;
}

From source file:com.samknows.measurement.test.TestExecutor.java

@SuppressWarnings("deprecation")
public void showNotification(String message) {
    String title = tc.getString(R.string.ntf_title);

    NotificationManager manager = (NotificationManager) tc.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification n = new Notification(R.drawable.icon, message, System.currentTimeMillis());
    PendingIntent intent = PendingIntent.getService(tc.getServiceContext(), Constants.RC_NOTIFICATION,
            new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
    n.setLatestEventInfo(tc.getServiceContext(), title, message, intent);
    manager.notify(Constants.NOTIFICATION_ID, n);
}

From source file:be.vbsteven.bmtodesk.BackgroundSharingService.java

/**
 * shows notification when the sending succeeded
 *//*from   w  w  w .  j  ava  2 s  .  com*/
private void showSuccessfulSend() {
    if (Global.isHideConfirmation(this)) {
        nManager.cancelAll();
    } else {
        Notification n = new Notification(R.drawable.icon, "Sending bookmark successful",
                System.currentTimeMillis());
        n.flags = Notification.FLAG_AUTO_CANCEL;
        Intent i = new Intent(this, AfterSuccessfulSendActivity.class);
        i.putExtra(Global.EXTRA_TITLE, title);
        i.putExtra(Global.EXTRA_URL, url);
        PendingIntent p = PendingIntent.getActivity(this, 4, i, 0);
        n.setLatestEventInfo(this, "Bookmark to Desktop", "Sending bookmark successful", p);
        nManager.notify(3, n);
    }
}

From source file:org.mythdroid.util.UpdateService.java

private void notify(String title, String message) {

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    Notification notification = new Notification(R.drawable.logo, title, System.currentTimeMillis());

    notification.flags = Notification.FLAG_AUTO_CANCEL;

    notification.setLatestEventInfo(getApplicationContext(), title, message,
            PendingIntent.getActivity(Globals.appContext, 0, new Intent(), 0));

    nm.notify(-1, notification);//from  w w w  .j a v  a  2  s.  com
}

From source file:uk.co.gidley.clockRadio.RadioPlayerService.java

private void showNotification() {
    // In this sample, we'll use the same text for the ticker and the
    // expanded notification
    CharSequence text = getText(R.string.local_service_started);

    // Set the icon, scrolling text and timestamp
    Notification notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());

    // The PendingIntent to launch our activity if the user selects this
    // notification
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ClockRadioActivity.class),
            0);//from   www  . j a v  a 2  s .  com

    // Set the info for the views that show in the notification panel.
    notification.setLatestEventInfo(this, getText(R.string.local_service_label), text, contentIntent);
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    startForeground(NOTIFICATION, notification);

    Log.d(TAG, "Show Notification Complete");

}

From source file:de.wikilab.android.friendica01.FileUploadService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.i("Andfrnd/UploadFile", "onHandleIntent exec");

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    //Instantiate the Notification:
    CharSequence tickerText = "Uploading...";
    Notification notification = new Notification(R.drawable.arrow_up, tickerText, System.currentTimeMillis());
    notification.flags |= Notification.FLAG_ONGOING_EVENT;

    //Define the Notification's expanded message and Intent:
    Context context = getApplicationContext();
    PendingIntent nullIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
    notification.setLatestEventInfo(context, "Upload in progress...", "You are notified here when it completes",
            nullIntent);//  w w  w.j  a  va2  s. c  o m

    //Pass the Notification to the NotificationManager:
    mNotificationManager.notify(UPLOAD_PROGRESS_ID, notification);
    /*
    final TwLogin login = new TwLogin();
    login.initialize(FileUploadService.this);
    login.doLogin(FileUploadService.this, null, false);
            
    if (!login.isLoginOK()) {
       showFailMsg(FileUploadService.this, "Invalid login data or no network connection");
       return;
    }
    */
    Bundle intentPara = intent.getExtras();
    fileToUpload = (Uri) intentPara.getParcelable(Intent.EXTRA_STREAM);
    descText = intentPara.getString(EXTRA_DESCTEXT);
    subject = intentPara.getString(Intent.EXTRA_SUBJECT);

    if (targetFilename == null || targetFilename.equals(""))
        targetFilename = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".txt";

    String fileSpec = Max.getRealPathFromURI(FileUploadService.this, fileToUpload);

    String tempFile = Max.IMG_CACHE_DIR + "/imgUploadTemp_" + System.currentTimeMillis() + ".jpg";
    Max.resizeImage(fileSpec, tempFile, 1024, 768);

    try {
        Log.i("Andfrnd/UploadFile", "before uploadFile");
        final TwAjax uploader = new TwAjax(FileUploadService.this, true, true);
        uploader.addPostFile(new TwAjax.PostFile("media", targetFilename, tempFile));
        uploader.addPostData("status", descText);
        uploader.addPostData("title", subject);
        uploader.addPostData("source",
                "<a href='http://friendica-for-android.wiki-lab.net'>Friendica for Android</a>");
        uploader.uploadFile(Max.getServer(this) + "/api/statuses/update", null);
        Log.i("Andfrnd/UploadFile", "after uploadFile");
        Log.i("Andfrnd/UploadFile", "isSuccess() = " + uploader.isSuccess());
        Log.i("Andfrnd/UploadFile", "getError() = " + uploader.getError());

        mNotificationManager.cancel(UPLOAD_PROGRESS_ID);
        if (uploader.isSuccess() && uploader.getError() == null) {
            JSONObject result = null;
            try {
                Log.i("Andfrnd/UploadFile", "JSON RESULT: " + uploader.getHttpCode());
                result = (JSONObject) uploader.getJsonResult();

                String postedText = result.getString("text");
                showSuccessMsg(FileUploadService.this);

            } catch (Exception e) {
                String errMes = e.getMessage() + " | " + uploader.getResult();
                if (result != null)
                    try {
                        errMes = result.getString("error");
                    } catch (JSONException fuuuuJava) {
                    }

                showFailMsg(FileUploadService.this, errMes);

                e.printStackTrace();
            }
        } else if (uploader.getError() != null) {
            showFailMsg(FileUploadService.this, uploader.getError().toString());
        } else {
            showFailMsg(FileUploadService.this, uploader.getResult());
        }

    } finally {
        new File(tempFile).delete();
    }
}

From source file:com.pendragon.blueconnect.BluetoothChat.java

public void displayNotification() {
    Intent i = new Intent("notify_filter");

    i.putExtra("notificationID", notificationID);
    PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.app_icon, "Notificacion Bluetooth",
            System.currentTimeMillis());
    CharSequence from = "Manager ";
    CharSequence message = "Nuevo mensaje recibido";
    notification.setLatestEventInfo(this, from, message, pi);
    notification.vibrate = new long[] { 100, 250, 100, 500 };
    nm.notify(notificationID, notification);

}

From source file:org.fdroid.enigtext.service.KeyCachingService.java

private void foregroundServiceLegacy() {
    Notification notification = new Notification(R.drawable.icon_cached,
            getString(R.string.KeyCachingService_textsecure_passphrase_cached), System.currentTimeMillis());
    Intent intent = new Intent(this, RoutingActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent launchIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
    notification.setLatestEventInfo(getApplicationContext(),
            getString(R.string.KeyCachingService_passphrase_cached),
            getString(R.string.KeyCachingService_textsecure_passphrase_cached), launchIntent);

    stopForeground(true);//  w  w  w  .j a v a2 s . co m
    startForeground(SERVICE_RUNNING_ID, notification);
}