List of usage examples for android.app Notification DEFAULT_ALL
int DEFAULT_ALL
To view the source code for android.app Notification DEFAULT_ALL.
Click Source Link
From source file:Main.java
public static void notifyShort(@NonNull Context context, @NonNull String title, String msg, @DrawableRes int iconId, @NonNull NotificationCompat.Action action, int nId) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL).setContentTitle(title).setContentText(msg) .setSmallIcon(iconId).addAction(action).setContentIntent(action.actionIntent).build(); notificationManager.notify(nId, notification); }
From source file:com.snippet.app.NotificationActivity.java
public void onButton1(final View v) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setDefaults(Notification.DEFAULT_ALL) .setLargeIcon(BitmapFactory.decodeResource(getResources(), android.R.drawable.sym_def_app_icon)) .setSmallIcon(android.R.drawable.stat_notify_chat).setTicker("Ticker") .setContentTitle("ContentTitle") .setContentText("ContentText: Hello world! The quick brown fox jumps over the lazy dog.") .setSubText("SubText").setContentInfo("10").setAutoCancel(true); Intent resultIntent = new Intent(this, NotificationResultActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(NotificationResultActivity.class); stackBuilder.addNextIntent(resultIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); notificationManager.notify(1, builder.build()); }
From source file:com.commonsware.android.fullscreen.MainActivity.java
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b = new NotificationCompat.Builder(this); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setTicker(getString(R.string.download_complete)) .setFullScreenIntent(buildPendingIntent(Settings.ACTION_DATE_SETTINGS), true) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return (b);// w w w.ja va2s .co m }
From source file:net.nym.library.util.Notify.java
/** * Displays a notification in the notification area of the UI * @param context Context from which to create the notification * @param messageString The string to display to the user as a message * @param smallIconId drawable id// ww w . j a va 2 s .c om * @param intent The intent which will start the activity when the user clicks the notification * @param notificationTitle The resource reference to the notification title * @return messageID */ public static int notifcation(Context context, String messageString, int smallIconId, Intent intent, int notificationTitle) { //Get the notification manage which we will use to display the notification String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); Calendar.getInstance().getTime().toString(); long when = System.currentTimeMillis(); //get the notification title from the application's strings.xml file CharSequence contentTitle = context.getString(notificationTitle); //the message that will be displayed as the ticker String ticker = contentTitle + " " + messageString; //build the pending intent that will start the appropriate activity PendingIntent pendingIntent = PendingIntent.getActivity(context, 3, intent, PendingIntent.FLAG_UPDATE_CURRENT); //build the notification Builder notificationCompat = new Builder(context); notificationCompat.setAutoCancel(true).setContentTitle(contentTitle).setContentIntent(pendingIntent) .setContentText(messageString).setTicker(ticker).setWhen(when).setSmallIcon(smallIconId); Notification notification = notificationCompat.build(); // notification.defaults |= Notification.DEFAULT_ALL; notification.defaults = Notification.DEFAULT_ALL; //display the notification mNotificationManager.notify(MessageID, notification); return MessageID++; }
From source file:cn.com.flashman.cordova.xpush.Baidu.java
static public void pushCallback(JSONObject r) { //???// w w w. j a va2 s .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:app.presentation.foundation.gcm.GcmReceiverBackground.java
private void showNotification(Message message, String title, String body, Application application) { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(application) .setContentTitle(title).setContentText(body).setDefaults(Notification.DEFAULT_ALL) .setSmallIcon(R.mipmap.ic_launcher).setAutoCancel(true) .setContentIntent(getPendingIntentForNotification(message)); NotificationManager notificationManager = (NotificationManager) application .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, notificationBuilder.build()); }
From source file:io.cordova.hellocordova.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set by <content src="index.html" /> in config.xml loadUrl(launchUrl);//from w ww . j a v a 2 s . c om Intent viewIntent = new Intent(this, ViewEventActivity.class); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0); Notification notification = new NotificationCompat.Builder(getApplication()) .setSmallIcon(R.drawable.ic_media_pause).setContentTitle("Hello Arshdeep") .setContentText("Status change for call center").setContentIntent(viewPendingIntent) .setDefaults(Notification.DEFAULT_ALL).build(); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplication()); int notificationId = 1; notificationManager.notify(notificationId, notification); }
From source file:com.chinatelecom.ctsi.workhelper.pushutil.Notify.java
/** * Displays a notification in the notification area of the UI * @param context Context from which to create the notification * @param messageString The string to display to the user as a message * @param intent The intent which will start the activity when the user clicks the notification * @param notificationTitle The resource reference to the notification title *//* w ww . ja va2s. c o m*/ public static void notifcation(Context context, String messageString, Intent intent, String title) { //Get the notification manage which we will use to display the notification String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); Calendar.getInstance().getTime().toString(); long when = System.currentTimeMillis(); //get the notification title from the application's strings.xml file // CharSequence contentTitle = context.getString(notificationTitle); //the message that will be displayed as the ticker String ticker = title + " " + messageString; //build the pending intent that will start the appropriate activity PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); //build the notification Builder notificationCompat = new Builder(context); notificationCompat.setAutoCancel(true).setContentTitle(title).setContentIntent(pendingIntent) .setContentText(messageString).setTicker(ticker).setWhen(when).setSmallIcon(R.drawable.ic_launcher); Notification notification = notificationCompat.build(); notification.defaults = Notification.DEFAULT_ALL; //display the notification mNotificationManager.notify(MessageID, notification); MessageID++; }
From source file:com.baasbox.android.samples.aloa.receive.NewMessageNotification.java
/** * Shows the notification, or updates a previously shown notification of * this type, with the given parameters. * <p>/*from w w w . ja v a 2 s . c o m*/ * TODO: Customize this method's arguments to present relevant content in * the notification. * <p> * TODO: Customize the contents of this method to tweak the behavior and * presentation of new message notifications. Make * sure to follow the * <a href="https://developer.android.com/design/patterns/notifications.html"> * Notification design guidelines</a> when doing so. * * @see #cancel(Context) */ public static void notify(final Context context, final String exampleString, final int number) { final Resources res = context.getResources(); final String ticker = exampleString; final String title = res.getString(R.string.new_message_notification_title_template, exampleString); final String text = res.getString(R.string.new_message_notification_placeholder_text_template, exampleString); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) // Set appropriate defaults for the notification light, sound, // and vibration. .setDefaults(Notification.DEFAULT_ALL) // Set required fields, including the small icon, the // notification title, and text. .setSmallIcon(R.drawable.ic_stat_new_message).setContentTitle(title).setContentText(text) // All fields below this line are optional. // Use a default priority (recognized on devices running Android // 4.1 or later) .setPriority(NotificationCompat.PRIORITY_DEFAULT) // Set ticker text (preview) information for this notification. .setTicker(ticker) // Show a number. This is useful when stacking notifications of // a single type. .setNumber(number) // Set the pending intent to be initiated when the user touches // the notification. .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT)) // Automatically dismiss the notification when it is touched. .setAutoCancel(true); notify(context, builder.build()); }
From source file:com.commonsware.android.bignotify.MainActivity.java
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b = new NotificationCompat.Builder(this); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis()) .setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setTicker(getString(R.string.download_complete)).setPriority(Notification.PRIORITY_HIGH) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return (b);/*from w w w.jav a 2 s. c om*/ }