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:com.skalski.raspberrycontrol.Custom_WebSocketClient.java
@Override public void onTextMessage(String payload) { Message payload_msg = new Message(); boolean send_message = false; try {// w w w . ja va 2s.c o m JSONObject jsonObj = new JSONObject(payload); if (jsonObj.has(TAG_HAN_GPIOSTATE)) if ((this.ClientHandler != null) && (this.ClientFilter.equals(TAG_HAN_GPIOSTATE))) send_message = true; if (jsonObj.has(TAG_HAN_TEMPSENSORS)) if ((this.ClientHandler != null) && (this.ClientFilter.equals(TAG_HAN_TEMPSENSORS))) send_message = true; if (jsonObj.has(TAG_HAN_PROCESSES)) if ((this.ClientHandler != null) && (this.ClientFilter.equals(TAG_HAN_PROCESSES))) send_message = true; if (jsonObj.has(TAG_HAN_STATISTICS)) if ((this.ClientHandler != null) && (this.ClientFilter.equals(TAG_HAN_STATISTICS))) send_message = true; if (jsonObj.has(TAG_ERROR)) if (this.ClientHandler != null) send_message = true; if (jsonObj.has(TAG_HAN_NOTIFICATION)) { if (Activity_Settings.pref_notifications_disabled(getBaseContext())) { Log.i(LOGTAG, LOGPREFIX + "notification: disabled"); } else { int notification_id; if (Activity_Settings.pref_multiple_notifications_disabled(getBaseContext())) notification_id = 0; else notification_id = (int) System.currentTimeMillis(); Notification new_notification = new Notification.Builder(this) .setContentTitle(getResources().getString(R.string.app_name)) .setContentText(jsonObj.getString(TAG_HAN_NOTIFICATION)) .setSmallIcon(R.drawable.ic_launcher).build(); new_notification.defaults |= Notification.DEFAULT_ALL; NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); notificationManager.notify(notification_id, new_notification); Log.i(LOGTAG, LOGPREFIX + "notification: " + notification_id); } } } catch (JSONException e) { Log.e(LOGTAG, LOGPREFIX + "can't parse JSON object"); } if (send_message) { payload_msg.obj = payload; ClientHandler.sendMessage(payload_msg); } }
From source file:com.ayyayo.g.Push.FIRMessagingService.java
private void sendNotification(Map<String, String> data) { // handle notification here /*/*from w w w . ja v a 2s.com*/ * types of notification 1. result update 2. circular update 3. student * corner update 4. App custom update 5. Custom Message 6. Notice from * College custom */ int num = ++NOTIFICATION_ID; Bundle msg = new Bundle(); for (String key : data.keySet()) { Log.e(key, data.get(key)); msg.putString(key, data.get(key)); } pref = getSharedPreferences("UPDATE_INSTANCE", MODE_PRIVATE); edit = pref.edit(); Intent backIntent; Intent intent = null; PendingIntent pendingIntent = null; backIntent = new Intent(getApplicationContext(), App.class); backIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); SharedPreferences sp; Editor editor; switch (Integer.parseInt(msg.getString("type"))) { case 1: break; case 2: backIntent = new Intent(getApplicationContext(), DailogeNotice.class); backIntent.putExtras(msg); stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(AppUpdate.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(backIntent); pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT); break; case 3: backIntent = new Intent(getApplicationContext(), CustomeWebView.class); backIntent.putExtras(msg); // The stack builder object will contain an artificial back stack // for the // started Activity. // This ensures that navigating backward from the Activity leads out // of // your application to the Home screen. stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(AppUpdate.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(backIntent); pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT); break; case 4: backIntent = new Intent(getApplicationContext(), App.class); // The stack builder object will contain an artificial back stack // for the // started Activity. // This ensures that navigating backward from the Activity leads out // of // your application to the Home screen. stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(AppUpdate.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(backIntent); pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT); DatabaseHandler db = new DatabaseHandler(getApplicationContext(), jsonConverter); db.addContact(new News(msg.getString("title"), msg.getString("msg"), msg.getString("link"), msg.getString("image")), DatabaseHandler.TABLE_NEWS); Intent intent_notify = new Intent(FCMActivity.NEW_NOTIFICATION); intent_notify.putExtra("DUMMY", "MUST"); sendBroadcast(intent_notify); break; default: break; } if (!is_noty) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setSmallIcon(R.drawable.ic_stat_fcm).setContentTitle(msg.getString("title")) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg.getString("msg").toString())) .setAutoCancel(true).setContentText(msg.getString("msg")); if (Integer.parseInt(msg.getString("type")) != 1) { mBuilder.setContentIntent(pendingIntent); } mBuilder.setDefaults(Notification.DEFAULT_ALL); mNotificationManager.notify(++NOTIFICATION_ID, mBuilder.build()); } }
From source file:com.hoangsong.zumechat.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * *//*from w ww.j a va 2 s. c om*/ private void sendNotification(CustomNotification customNotification) { String title = getString(R.string.app_name); long when = System.currentTimeMillis(); NotificationCompat.Builder mBuilder = null; if (customNotification.getSound().equals("0") && customNotification.getVibrate().equals("0")) { mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } else if (customNotification.getSound().equals("1")) { mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setDefaults(Notification.DEFAULT_SOUND).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } else if (customNotification.getVibrate().equals("1")) { mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setDefaults(Notification.DEFAULT_VIBRATE).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } else { Log.e(Constants.TAG, MyGcmListenerService.class.getName() + " Exception: test all"); mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } // Creates an explicit intent for an Activity in your app Intent notificationIntent = new Intent(getApplicationContext(), MainActivityPhone.class); if (customNotification != null) { Bundle bundle = new Bundle(); bundle.putSerializable("customNotification", customNotification); notificationIntent.putExtras(bundle); } notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext()); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivityPhone.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(notificationIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(customNotification.getId(), PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(customNotification.getId(), mBuilder.build()); //Constants.NOTIFICATION_TYPE_ANNOUNCEMENT, mBuilder.build()); }
From source file:com.marmalade.studio.android.gcm.s3eGCMClientBroadcastReceiver.java
private void sendNotification(String msg) { // Get notification manager NotificationManager notification = (NotificationManager) m_Context .getSystemService(Context.NOTIFICATION_SERVICE); // Get intent Intent intent = m_Context.getPackageManager().getLaunchIntentForPackage(m_Context.getPackageName()); if (null != intent) { // Add flag intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Create content intent PendingIntent content_intent = PendingIntent.getActivity(m_Context, 0, intent, 0); // Create notification compat builder NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(m_Context).setAutoCancel(true) .setContentText(msg).setContentTitle(getGameTitle()).setSmallIcon(getIconId()) .setDefaults(Notification.DEFAULT_ALL) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)); // Set content intent mBuilder.setContentIntent(content_intent); // Notify notification.notify(m_NotificationId, mBuilder.build()); }//from w ww . j a v a 2 s .c o m }
From source file:com.lloydtorres.stately.push.TrixHelper.java
/** * Returns a NotificationCompat builder with set parameters common to all notifications from Stately. * @return See above//w w w . ja v a2s . c o m */ private static NotificationCompat.Builder getBaseBuilder(Context c, String account) { int primaryColour = RaraHelper.getThemePrimaryColour(c); return new NotificationCompat.Builder(c).setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true) .setColor(primaryColour) .setContentText(String.format(Locale.US, c.getString(R.string.stately_notifs_sub_template), SparkleHelper.getNameFromId(account))) .setLights(primaryColour, LED_DURATION_MS, LED_DURATION_MS); }
From source file:me.publicar.flashofertas.Push.FIRMessagingService.java
private void sendNotification(Map<String, String> data) { // handle notification here /*//from w ww .ja v a 2 s . c o m * types of notification 1. result update 2. circular update 3. student * corner update 4. App custom update 5. Custom Message 6. Notice from * College custom */ int num = ++NOTIFICATION_ID; Bundle msg = new Bundle(); for (String key : data.keySet()) { Log.e(key, data.get(key)); msg.putString(key, data.get(key)); } pref = getSharedPreferences("UPDATE_INSTANCE", MODE_PRIVATE); edit = pref.edit(); Intent backIntent; Intent intent = null; PendingIntent pendingIntent = null; backIntent = new Intent(getApplicationContext(), SplashScreen.class); backIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); SharedPreferences sp; Editor editor; switch (Integer.parseInt(msg.getString("type"))) { case 1: break; case 2: backIntent = new Intent(getApplicationContext(), DailogeNotice.class); backIntent.putExtras(msg); stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(AppUpdate.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(backIntent); pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT); break; case 3: backIntent = new Intent(getApplicationContext(), CustomeWebView.class); backIntent.putExtras(msg); // The stack builder object will contain an artificial back stack // for the // started Activity. // This ensures that navigating backward from the Activity leads out // of // your application to the Home screen. stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(AppUpdate.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(backIntent); pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT); break; case 4: backIntent = new Intent(getApplicationContext(), SplashScreen.class); // The stack builder object will contain an artificial back stack // for the // started Activity. // This ensures that navigating backward from the Activity leads out // of // your application to the Home screen. stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(AppUpdate.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(backIntent); pendingIntent = stackBuilder.getPendingIntent(num, PendingIntent.FLAG_UPDATE_CURRENT); DatabaseHandler db = new DatabaseHandler(getApplicationContext()); db.addContact(new News(msg.getString("title"), msg.getString("msg"), msg.getString("link"), msg.getString("image")), DatabaseHandler.TABLE_NEWS); Intent intent_notify = new Intent(FCMActivity.NEW_NOTIFICATION); intent_notify.putExtra("DUMMY", "MUST"); sendBroadcast(intent_notify); break; default: break; } if (!is_noty) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle(msg.getString("title")) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg.getString("msg").toString())) .setAutoCancel(true).setContentText(msg.getString("msg")); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setSmallIcon(R.drawable.ic_launcher); } else { mBuilder.setSmallIcon(R.drawable.ic_launcher_fcm); } if (Integer.parseInt(msg.getString("type")) != 1) { mBuilder.setContentIntent(pendingIntent); } mBuilder.setDefaults(Notification.DEFAULT_ALL); mNotificationManager.notify(++NOTIFICATION_ID, mBuilder.build()); } }
From source file:ufms.br.com.ufmsapp.gcm.UfmsGcmListenerService.java
private void buildGcmNotificationEvento(String title, String msg, Class mClass, String intentExtraName, String valueId, String disciplina) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); boolean isSoundEnabled = prefs.getBoolean(getResources().getString(R.string.pref_notification_sound), true); NotificationManagerCompat nm = NotificationManagerCompat.from(this); Intent it = new Intent(this, mClass); it.putExtra(intentExtraName, valueId); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addNextIntent(it);// w ww . j a v a2s.c om PendingIntent pit = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); if (isSoundEnabled) { mBuilder.setDefaults(Notification.DEFAULT_ALL); } NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); bigTextStyle.setBigContentTitle(title).setSummaryText(disciplina).bigText(msg); mBuilder.setStyle(bigTextStyle); mBuilder.setAutoCancel(true); mBuilder.setContentIntent(pit); mBuilder.setColor(ContextCompat.getColor(this, R.color.accentColor)); mBuilder.setSmallIcon(R.mipmap.ic_launcher_white); mBuilder.setContentTitle(title); mBuilder.setContentText(msg); nm.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.snippet.app.NotificationActivity.java
public void onButton6(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("Running..") .setContentTitle("Ongoing notification") .setContentText("Remove me by NotificationManager#cancel(int).").setSubText("SubText") .setContentInfo("10").setOngoing(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(6, builder.build()); }
From source file:com.odoo.core.utils.notification.ONotificationBuilder.java
private void _setResultIntent() { mNotificationResultIntent = PendingIntent.getActivity(mContext, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationBuilder.setDefaults(Notification.DEFAULT_ALL); mNotificationBuilder.setContentIntent(mNotificationResultIntent); }
From source file:com.mobileman.moments.android.frontend.activity.IncomingCallActivity.java
public static void sendGeneralNotificationOfMissedCall(Context context, String userName, String title) { Intent intent = new Intent(context, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder b = new NotificationCompat.Builder(context); String notificationTitle = userName + " " + context.getResources().getString(R.string.isLiveSuffix); String notificationText = title; NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); b.setAutoCancel(true).setSmallIcon(R.drawable.ic_launcher).setDefaults(Notification.DEFAULT_ALL) .setWhen(System.currentTimeMillis()).setTicker("X").setContentTitle(notificationTitle) .setContentText(notificationText) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND) .setContentIntent(contentIntent); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(++NOTIFICATION_COUNTER, b.build()); }