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.innoc.secureline.ui.NotificationBarManager.java

public static void setCallInProgress(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Intent contentIntent = new Intent(context, SecureLine.class);
    contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0);
    String notificationText = context.getString(R.string.NotificationBarManager_redphone_call_in_progress);
    Notification notification = new Notification(R.drawable.stat_sys_phone_call, null,
            System.currentTimeMillis());

    notification.setLatestEventInfo(context, notificationText, notificationText, pendingIntent);
    notification.flags = Notification.FLAG_NO_CLEAR;
    notificationManager.notify(RED_PHONE_NOTIFICATION, notification);
}

From source file:com.mindprotectionkit.freephone.ui.NotificationBarManager.java

public static void setCallInProgress(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Intent contentIntent = new Intent(context, RedPhone.class);
    contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0);
    String notificationText = context.getString(R.string.NotificationBarManager_redphone_call_in_progress);
    Notification notification = new Notification(R.drawable.stat_sys_phone_call, null,
            System.currentTimeMillis());

    notification.setLatestEventInfo(context, notificationText, notificationText, pendingIntent);
    notification.flags = Notification.FLAG_NO_CLEAR;
    notificationManager.notify(RED_PHONE_NOTIFICATION, notification);
}

From source file:org.pixmob.droidlink.service.DeviceInitService.java

private static Notification createNotification(Context context, String account, PendingIntent pi) {
    final Notification n = new Notification(android.R.drawable.stat_notify_sync,
            context.getString(R.string.device_setup_running), System.currentTimeMillis());
    n.setLatestEventInfo(context.getApplicationContext(), context.getString(R.string.device_setup_running),
            account, pi);//www . j  av  a 2 s  . co m
    return n;
}

From source file:net.frygo.findmybuddy.GCMIntentService.java

private static void generateNotification(Context context, String message) {

    Random rand = new Random();
    int x = rand.nextInt();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, customlistview.class);
    notificationIntent.putExtra("alert", message);
    message = message + " would like to add you as friend";
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT);

    Notification notification = new Notification(R.drawable.logo, message, System.currentTimeMillis());
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(x, notification);

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    final PowerManager.WakeLock mWakelock = pm
            .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, title);
    mWakelock.acquire();/*w w w .j  a  v  a 2  s. co m*/

    // Timer before putting Android Device to sleep mode.
    Timer timer = new Timer();
    TimerTask task = new TimerTask() {
        public void run() {
            mWakelock.release();
        }
    };
    timer.schedule(task, 5000);

}

From source file:net.frygo.findmybuddy.GCMIntentService.java

private static void generateAcceptfriendNotification(Context context, String message, String status) {

    Random rand = new Random();
    int x = rand.nextInt();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, customlistview.class);
    if (status.equalsIgnoreCase("accept"))
        message = message + " added you as buddy";
    else/* w w  w.  j  a va2s  .  co  m*/
        message = message + " rejected you as buddy";
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT);

    Notification notification = new Notification(R.drawable.logo, message, System.currentTimeMillis());
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(x, notification);

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    final PowerManager.WakeLock mWakelock = pm
            .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, title);
    mWakelock.acquire();

    // Timer before putting Android Device to sleep mode.
    Timer timer = new Timer();
    TimerTask task = new TimerTask() {
        public void run() {
            mWakelock.release();
        }
    };
    timer.schedule(task, 5000);

}

From source file:cn.com.flashman.cordova.xpush.Baidu.java

static public void pushCallback(JSONObject r) {
    //???/*from w  w w .  j  a v  a2s  .c o  m*/
    if (isActive && !webview.isFinishing()) {
        webview.sendJavascript("cordova.plugins.XPush.Baidu.pushCheck()");

        //?????
    } else {
        try {
            if (r.getString("type") == "message") {
                JSONObject info = new JSONObject(r.getString("message"));
                String title = info.getString("title");
                String desc = info.getString("description");
                NotificationManager nm = (NotificationManager) webview
                        .getSystemService(webview.NOTIFICATION_SERVICE);
                Notification notification = new Notification(icon, title, System.currentTimeMillis());
                notification.defaults = Notification.DEFAULT_ALL;
                PendingIntent pt = PendingIntent.getActivity(webview, 0,
                        new Intent(webview, webview.getClass()), 0);
                notification.setLatestEventInfo(webview, title, desc, pt);
                nm.notify(nitify_id, notification);
            }
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:menion.android.whereyougo.gui.extension.activity.CustomActivity.java

public static void setStatusbar(Activity activity) {
    try {//w ww . java 2 s . c  o  m
        NotificationManager mNotificationManager = (NotificationManager) activity
                .getSystemService(Context.NOTIFICATION_SERVICE);
        // set statusbar
        if (Preferences.APPEARANCE_STATUSBAR) {
            Context context = activity.getApplicationContext();
            Intent intent = new Intent(context, menion.android.whereyougo.gui.activity.MainActivity.class);
            // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setAction(Intent.ACTION_MAIN);
            PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);
            final int sdkVersion = Integer.parseInt(android.os.Build.VERSION.SDK);
            Notification notif = null;
            if (sdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
                notif = new Notification(R.drawable.ic_title_logo, A.getAppName(), System.currentTimeMillis());
                notif.setLatestEventInfo(activity, A.getAppName(), "", pIntent);
            } else {
                NotificationCompat.Builder builder = new NotificationCompat.Builder(activity)
                        .setContentTitle(A.getAppName()).setSmallIcon(R.drawable.ic_title_logo)
                        .setContentIntent(pIntent);
                notif = builder.build();
            }
            notif.flags = Notification.FLAG_ONGOING_EVENT;
            mNotificationManager.notify(0, notif);
        } else {
            mNotificationManager.cancel(0);
        }
    } catch (Exception e) {
        // Logger.e(TAG, "setStatusbar(" + activity + ")", e);
    }
}

From source file:com.tcnr14.example.GCMIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *///from  w  ww.  j a v  a  2  s  .  co  m
private static void generateNotification(Context context, String message) {
    int icon = R.drawable.ic_launcher;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, MainActivity.class);
    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(0, notification);
}

From source file:com.cbtec.eliademy.GCMIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *//*from  w  w  w . ja  v a 2 s  . c om*/

private static void generateNotification(Context context, String message) {
    int icon = R.drawable.icon;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, Eliademy.class);
    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(0, notification);
}

From source file:no.ntnu.wifimanager.GCMIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *///from  w w w.  j  ava2 s  . c o m
private static void generateNotification(Context context, String message) {
    int icon = R.drawable.ic_stat_gcm;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, ClientListActivity.class);
    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(0, notification);
}