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.roamprocess1.roaming4world.service.SipNotifications.java
public void showNotificationForMissedCall(ContentValues callLog) { int icon = android.R.drawable.stat_notify_missed_call; CharSequence tickerText = context.getText(R.string.missed_call); long when = System.currentTimeMillis(); if (missedCallNotification == null) { missedCallNotification = new NotificationCompat.Builder(context); missedCallNotification.setSmallIcon(icon); missedCallNotification.setTicker(tickerText); missedCallNotification.setWhen(when); missedCallNotification.setOnlyAlertOnce(true); missedCallNotification.setAutoCancel(true); missedCallNotification.setDefaults(Notification.DEFAULT_ALL); }// ww w . j a va2s.com System.out.println("showNotificationForMissedCall"); Intent notificationIntent = new Intent("com.roamprocess1.roaming4world.R4wHome.R4w_ACTIVITY"); // Intent notificationIntent = new Intent(SipManager.ACTION_SIP_CALLLOG); System.out.println("Misscall Notification"); //notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); String remoteContact = callLog.getAsString(CallLog.Calls.NUMBER); System.out.println("remoteContact vlaue " + remoteContact); String[] parts = remoteContact.split("@"); String part1 = parts[0]; // 004 String[] part3 = part1.split(":"); String part5 = part3[1]; System.out.println("part5 ==" + part5); long accId = callLog.getAsLong(SipManager.CALLLOG_PROFILE_ID_FIELD); missedCallNotification.setContentTitle(formatNotificationTitle(R.string.missed_call, accId)); missedCallNotification.setContentText(formatRemoteContactString(part5)); System.out.println("remoteContact vlaue ==" + remoteContact); missedCallNotification.setContentIntent(contentIntent); notificationManager.notify(CALLLOG_NOTIF_ID, missedCallNotification.build()); }
From source file:com.fututel.service.SipNotifications.java
public void showNotificationForMessage(SipMessage msg) { if (!CustomDistribution.supportMessaging()) { return;/* w w w .j a v a2 s . co m*/ } // CharSequence tickerText = context.getText(R.string.instance_message); if (!msg.getFrom().equalsIgnoreCase(viewingRemoteFrom)) { String from = formatRemoteContactString(msg.getFullFrom()); if (from.equalsIgnoreCase(msg.getFullFrom())) { from = msg.getDisplayName() + " " + from; } CharSequence tickerText = buildTickerMessage(context, from, msg.getBody()); if (messageNotification == null) { messageNotification = new NotificationCompat.Builder(context); messageNotification.setSmallIcon(SipUri.isPhoneNumber(from) ? R.drawable.stat_notify_sms : android.R.drawable.stat_notify_chat); messageNotification.setTicker(tickerText); messageNotification.setWhen(System.currentTimeMillis()); messageNotification.setDefaults(Notification.DEFAULT_ALL); messageNotification.setAutoCancel(true); messageNotification.setOnlyAlertOnce(true); } Intent notificationIntent = new Intent(SipManager.ACTION_SIP_MESSAGES); notificationIntent.putExtra(SipMessage.FIELD_FROM, msg.getFrom()); notificationIntent.putExtra(SipMessage.FIELD_BODY, msg.getBody()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); messageNotification.setContentTitle(from); messageNotification.setContentText(msg.getBody()); messageNotification.setContentIntent(contentIntent); notificationManager.notify(MESSAGE_NOTIF_ID, messageNotification.build()); } }
From source file:org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationsPlugin.java
@Override public boolean onPackageReceived(final NetworkPackage np) { if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_NOTIFICATION)) return false; /*/* w w w. j a va 2 s . c o m*/ if (np.getBoolean("sendIcons")) { sendIcons = true; } */ if (np.getBoolean("request")) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) NotificationReceiver.RunCommand(context, new NotificationReceiver.InstanceCallback() { private void sendCurrentNotifications(NotificationReceiver service) { StatusBarNotification[] notifications = service.getActiveNotifications(); for (StatusBarNotification notification : notifications) { sendNotification(notification, true); } } @Override public void onServiceStart(final NotificationReceiver service) { try { //If service just started, this call will throw an exception because the answer is not ready yet sendCurrentNotifications(service); } catch (Exception e) { Log.e("onPackageReceived", "Error when answering 'request': Service failed to start. Retrying in 100ms..."); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(100); Log.e("onPackageReceived", "Error when answering 'request': Service failed to start. Retrying..."); sendCurrentNotifications(service); } catch (Exception e) { Log.e("onPackageReceived", "Error when answering 'request': Service failed to start twice!"); e.printStackTrace(); } } }).start(); } } }); } else if (np.has("cancel")) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) NotificationReceiver.RunCommand(context, new NotificationReceiver.InstanceCallback() { @Override public void onServiceStart(NotificationReceiver service) { String dismissedId = np.getString("cancel"); cancelNotificationCompat(service, dismissedId); } }); } else { if (!np.has("ticker") || !np.has("appName") || !np.has("id")) { Log.e("NotificationsPlugin", "Received notification package lacks properties"); } else { TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MaterialActivity.class); stackBuilder.addNextIntent(new Intent(context, MaterialActivity.class)); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); Bitmap largeIcon = null; if (np.hasPayload()) { int width = 64; // default icon dimensions int height = 64; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { width = context.getResources() .getDimensionPixelSize(android.R.dimen.notification_large_icon_width); height = context.getResources() .getDimensionPixelSize(android.R.dimen.notification_large_icon_height); } final InputStream input = np.getPayload(); largeIcon = BitmapFactory.decodeStream(np.getPayload()); try { input.close(); } catch (Exception e) { } if (largeIcon != null) { //Log.i("NotificationsPlugin", "hasPayload: size=" + largeIcon.getWidth() + "/" + largeIcon.getHeight() + " opti=" + width + "/" + height); if (largeIcon.getWidth() > width || largeIcon.getHeight() > height) { // older API levels don't scale notification icons automatically, therefore: largeIcon = Bitmap.createScaledBitmap(largeIcon, width, height, false); } } } Notification noti = new NotificationCompat.Builder(context).setContentTitle(np.getString("appName")) .setContentText(np.getString("ticker")).setContentIntent(resultPendingIntent) .setTicker(np.getString("ticker")).setSmallIcon(android.R.drawable.ic_dialog_alert) .setLargeIcon(largeIcon).setAutoCancel(true).setLocalOnly(true) // to avoid bouncing the notification back to other kdeconnect nodes .setDefaults(Notification.DEFAULT_ALL).build(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); try { // tag all incoming notifications notificationManager.notify("kdeconnectId:" + np.getString("id", "0"), np.getInt("id", 0), noti); } catch (Exception e) { //4.1 will throw an exception about not having the VIBRATE permission, ignore it. //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/ } } } return true; }
From source file:com.csipsimple.service.SipNotifications.java
public void showNotificationForMessage(SipMessage msg) { if (!CustomDistribution.supportMessaging()) { return;/* w w w. j ava 2 s . c om*/ } // CharSequence tickerText = context.getText(R.string.instance_message); if (!msg.getFrom().equalsIgnoreCase(viewingRemoteFrom)) { String from = formatRemoteContactString(msg.getFullFrom()); if (from.equalsIgnoreCase(msg.getFullFrom()) && !from.equals(msg.getDisplayName())) { from = msg.getDisplayName() + " " + from; } CharSequence tickerText = buildTickerMessage(context, from, msg.getBody()); if (messageNotification == null) { messageNotification = new NotificationCompat.Builder(context); messageNotification.setSmallIcon(SipUri.isPhoneNumber(from) ? R.drawable.stat_notify_sms : android.R.drawable.stat_notify_chat); messageNotification.setTicker(tickerText); messageNotification.setWhen(System.currentTimeMillis()); messageNotification.setDefaults(Notification.DEFAULT_ALL); messageNotification.setAutoCancel(true); messageNotification.setOnlyAlertOnce(true); } Intent notificationIntent = new Intent(SipManager.ACTION_SIP_MESSAGES); notificationIntent.putExtra(SipMessage.FIELD_FROM, msg.getFrom()); notificationIntent.putExtra(SipMessage.FIELD_BODY, msg.getBody()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); messageNotification.setContentTitle(from); messageNotification.setContentText(msg.getBody()); messageNotification.setContentIntent(contentIntent); notificationManager.notify(MESSAGE_NOTIF_ID, messageNotification.build()); } }
From source file:com.sip.pwc.sipphone.service.SipNotifications.java
public void showNotificationForMessage(SipMessage msg) { if (!CustomDistribution.supportMessaging()) { return;/*www. ja v a2s.co m*/ } // CharSequence tickerText = context.getText(R.string.instance_message); if (!msg.getFrom().equalsIgnoreCase(viewingRemoteFrom)) { String from = formatRemoteContactString(msg.getFullFrom()); if (from.equalsIgnoreCase(msg.getFullFrom()) && !from.equals(msg.getDisplayName())) { from = msg.getDisplayName() + " " + from; } CharSequence tickerText = buildTickerMessage(context, from, msg.getBody()); if (messageNotification == null) { messageNotification = new NotificationCompat.Builder(context); messageNotification.setSmallIcon(SipUri.isPhoneNumber(from) ? R.mipmap.stat_notify_sms : android.R.drawable.stat_notify_chat); messageNotification.setTicker(tickerText); messageNotification.setWhen(System.currentTimeMillis()); messageNotification.setDefaults(Notification.DEFAULT_ALL); messageNotification.setAutoCancel(true); messageNotification.setOnlyAlertOnce(true); } Intent notificationIntent = new Intent(SipManager.ACTION_SIP_MESSAGES); notificationIntent.putExtra(SipMessage.FIELD_FROM, msg.getFrom()); notificationIntent.putExtra(SipMessage.FIELD_BODY, msg.getBody()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); messageNotification.setContentTitle(from); messageNotification.setContentText(msg.getBody()); messageNotification.setContentIntent(contentIntent); notificationManager.notify(MESSAGE_NOTIF_ID, messageNotification.build()); } }
From source file:com.voiceblue.phone.service.SipNotifications.java
public void showNotificationForMessage(SipMessage msg) { if (!CustomDistribution.supportMessaging()) { return;/* w w w.j av a 2s . com*/ } // CharSequence tickerText = context.getText(R.string.instance_message); if (!msg.getFrom().equalsIgnoreCase(viewingRemoteFrom)) { String from = formatRemoteContactString(msg.getFullFrom()); if (from.equalsIgnoreCase(msg.getFullFrom()) && !from.equals(msg.getDisplayName())) { from = msg.getDisplayName() + " " + from; } CharSequence tickerText = buildTickerMessage(context, from, msg.getBody()); if (messageNotification == null) { messageNotification = new NotificationCompat.Builder(context); messageNotification.setSmallIcon(SipUri.isPhoneNumber(from) ? R.drawable.stat_notify_sms : android.R.drawable.stat_notify_chat); messageNotification.setTicker(tickerText); messageNotification.setWhen(System.currentTimeMillis()); messageNotification.setDefaults(Notification.DEFAULT_ALL); messageNotification.setAutoCancel(true); messageNotification.setOnlyAlertOnce(true); } Intent notificationIntent = new Intent(SipManager.ACTION_SIP_MESSAGES); notificationIntent.putExtra(SipMessage.FIELD_FROM, msg.getFrom()); notificationIntent.putExtra(SipMessage.FIELD_BODY, msg.getBody()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); messageNotification.setContentTitle(from); messageNotification.setContentText(msg.getBody()); messageNotification.setContentIntent(contentIntent); notificationManager.notify(MESSAGE_NOTIF_ID, messageNotification.build()); } }
From source file:com.parse.ParsePushBroadcastReceiver.java
/** * Creates a {@link Notification} with reasonable defaults. If "alert" and "title" are * both missing from data, then returns {@code null}. If the text in the notification is longer * than 38 characters long, the style of the notification will be set to * {@link android.app.Notification.BigTextStyle}. * <p/>/* w w w. j a v a 2s.c om*/ * As a security precaution, developers overriding this method should be sure to set the package * on notification {@code Intent}s to avoid leaking information to other apps. * * @param context * The {@code Context} in which the receiver is running. * @param intent * An {@code Intent} containing the channel and data of the current push notification. * @return * The notification to be displayed. * * @see ParsePushBroadcastReceiver#onPushReceive(Context, Intent) */ protected Notification getNotification(Context context, Intent intent) { JSONObject pushData = getPushData(intent); if (pushData == null || (!pushData.has("alert") && !pushData.has("title"))) { return null; } String title = pushData.optString("title", ManifestInfo.getDisplayName(context)); String alert = pushData.optString("alert", "Notification received."); String tickerText = String.format(Locale.getDefault(), "%s: %s", title, alert); Bundle extras = intent.getExtras(); Random random = new Random(); int contentIntentRequestCode = random.nextInt(); int deleteIntentRequestCode = random.nextInt(); // Security consideration: To protect the app from tampering, we require that intent filters // not be exported. To protect the app from information leaks, we restrict the packages which // may intercept the push intents. String packageName = context.getPackageName(); Intent contentIntent = new Intent(ParsePushBroadcastReceiver.ACTION_PUSH_OPEN); contentIntent.putExtras(extras); contentIntent.setPackage(packageName); Intent deleteIntent = new Intent(ParsePushBroadcastReceiver.ACTION_PUSH_DELETE); deleteIntent.putExtras(extras); deleteIntent.setPackage(packageName); PendingIntent pContentIntent = PendingIntent.getBroadcast(context, contentIntentRequestCode, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pDeleteIntent = PendingIntent.getBroadcast(context, deleteIntentRequestCode, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT); // The purpose of setDefaults(Notification.DEFAULT_ALL) is to inherit notification properties // from system defaults NotificationCompat.Builder parseBuilder = new NotificationCompat.Builder(context); parseBuilder.setContentTitle(title).setContentText(alert).setTicker(tickerText) .setSmallIcon(this.getSmallIconId(context, intent)).setLargeIcon(this.getLargeIcon(context, intent)) .setContentIntent(pContentIntent).setDeleteIntent(pDeleteIntent).setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL); if (alert != null && alert.length() > ParsePushBroadcastReceiver.SMALL_NOTIFICATION_MAX_CHARACTER_LIMIT) { parseBuilder.setStyle(new NotificationCompat.Builder.BigTextStyle().bigText(alert)); } return parseBuilder.build(); }
From source file:com.polkapolka.bluetooth.le.DeviceControlActivity.java
public static void showNotificationInMenu(Context context) { // variables/*from w ww . jav a2 s. com*/ long currentTime = System.currentTimeMillis(); // guard: check if we should wait if (currentTime - lastNotificationTime < NOTIFICATION_DELAY) { return; } lastNotificationTime = currentTime; NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setContentTitle(context.getString(R.string.NotifationTitle)) .setContentText(context.getString(R.string.NotificationSubtitle)) .setTicker(context.getString(R.string.BadPostureTicker)).setSmallIcon(R.drawable.icon); // Define that we have the intention of opening MoreInfoNotification Intent moreInfoIntent = new Intent(context, userActivity.class); // Used to stack tasks across activites so we go to the proper place when back is clicked TaskStackBuilder tStackBuilder = TaskStackBuilder.create(context); // Add all parents of this activity to the stack tStackBuilder.addParentStack(DeviceControlActivity.class); // Add our new Intent to the stack tStackBuilder.addNextIntent(moreInfoIntent); // default_all -> vibrate light and sound DEFAULT_VIBRATE -> only vibration even with sound on. notificationBuilder.setDefaults(Notification.DEFAULT_ALL); notificationBuilder.setAutoCancel(true); // Define an Intent and an action to perform with it by another application // FLAG_UPDATE_CURRENT : If the intent exists keep it but update it if needed PendingIntent pendingIntent = tStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); // Defines the Intent to fire when the notification is clicked notificationBuilder.setContentIntent(pendingIntent); // Gets a NotificationManager which is used to notify the user of the background event NotificationManager notificationManager; notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Post the notification notificationManager.notify(notifID, notificationBuilder.build()); }
From source file:com.csipsimple.service.SipNotifications.java
public void showNotificationForVoiceMail(SipProfile acc, int numberOfMessages) { if (messageVoicemail == null) { messageVoicemail = new NotificationCompat.Builder(context); messageVoicemail.setSmallIcon(android.R.drawable.stat_notify_voicemail); messageVoicemail.setTicker(context.getString(R.string.voice_mail)); messageVoicemail.setWhen(System.currentTimeMillis()); messageVoicemail.setDefaults(Notification.DEFAULT_ALL); messageVoicemail.setAutoCancel(true); messageVoicemail.setOnlyAlertOnce(true); }/*from w w w. j av a 2 s.c om*/ PendingIntent contentIntent = null; Intent notificationIntent; if (acc != null && !TextUtils.isEmpty(acc.vm_nbr) && acc.vm_nbr != "null") { notificationIntent = new Intent(Intent.ACTION_CALL); notificationIntent.setData( SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, acc.vm_nbr + "@" + acc.getDefaultDomain())); notificationIntent.putExtra(SipProfile.FIELD_ACC_ID, acc.id); } else { notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER); } notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); String messageText = ""; if (acc != null) { messageText += acc.getProfileName() + " : "; } messageText += Integer.toString(numberOfMessages); messageVoicemail.setContentTitle(context.getString(R.string.voice_mail)); messageVoicemail.setContentText(messageText); if (contentIntent != null) { messageVoicemail.setContentIntent(contentIntent); notificationManager.notify(VOICEMAIL_NOTIF_ID, messageVoicemail.build()); } }
From source file:com.sip.pwc.sipphone.service.SipNotifications.java
public void showNotificationForVoiceMail(SipProfile acc, int numberOfMessages) { if (messageVoicemail == null) { messageVoicemail = new NotificationCompat.Builder(context); messageVoicemail.setSmallIcon(android.R.drawable.stat_notify_voicemail); messageVoicemail.setTicker(context.getString(R.string.voice_mail)); messageVoicemail.setWhen(System.currentTimeMillis()); messageVoicemail.setDefaults(Notification.DEFAULT_ALL); messageVoicemail.setAutoCancel(true); messageVoicemail.setOnlyAlertOnce(true); }/*from www . j ava 2s .c om*/ PendingIntent contentIntent = null; Intent notificationIntent; if (acc != null && !TextUtils.isEmpty(acc.vm_nbr) && acc.vm_nbr != "null") { notificationIntent = new Intent(Intent.ACTION_CALL); notificationIntent.setData( SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, acc.vm_nbr + "@" + acc.getDefaultDomain())); notificationIntent.putExtra(SipProfile.FIELD_ACC_ID, acc.id); } else { notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER); } notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); String messageText = ""; if (acc != null) { messageText += acc.getProfileName(); if (numberOfMessages > 0) { messageText += " : "; } } if (numberOfMessages > 0) { messageText += Integer.toString(numberOfMessages); } messageVoicemail.setContentTitle(context.getString(R.string.voice_mail)); messageVoicemail.setContentText(messageText); if (contentIntent != null) { messageVoicemail.setContentIntent(contentIntent); notificationManager.notify(VOICEMAIL_NOTIF_ID, messageVoicemail.build()); } }