List of usage examples for android.app Notification DEFAULT_SOUND
int DEFAULT_SOUND
To view the source code for android.app Notification DEFAULT_SOUND.
Click Source Link
From source file:uk.co.jarofgreen.cityoutdoors.Service.SendFeatureContentOrReportService.java
protected void onHandleIntent(Intent intent) { OurApplication ourApp = (OurApplication) getApplication(); if (ourApp.hasMoreToUpload()) { BaseUploadContentOrReport upload = ourApp.getNextToUpload(); int featureID = upload.hasFeatureID() ? upload.getFeatureID() : -1; // ---------- Start Ongoing Notification int icon = R.drawable.notification; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, "Sending", when); Intent notificationIntent = new Intent(this, SendFeatureContentOrReportProgressActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(getApplicationContext(), getString(R.string.send_feature_content_or_report_service_notification_content_title), getString(R.string.send_feature_content_or_report_service_notification_content_text), contentIntent);//from ww w .j av a2s . co m notification.flags = Notification.DEFAULT_SOUND; notification.flags |= Notification.DEFAULT_VIBRATE; notification.flags |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_ONGOING_EVENT; NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(SendFeatureContentOrReportService.NOTIFICATION_ID, notification); //------------ Send if (upload instanceof UploadFeatureContent) { sendFeatureContent((UploadFeatureContent) upload); } else if (upload instanceof UploadFeatureReport) { sendFeatureReport((UploadFeatureReport) upload); } //----------- Remove from que ourApp.removeUploadFromQue(upload); // ---------- End Ongoing Notification if (!ourApp.hasMoreToUpload()) { mNotificationManager.cancel(SendFeatureContentOrReportService.NOTIFICATION_ID); } } }
From source file:in.com.ralarm.alert.AlarmAlertBroadcastReciever.java
private void sendNotification(String extras) { mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); // decide to open global push or single PendingIntent contentIntent;//www. j a va2 s . com contentIntent = PendingIntent.getActivity(ctx, 0, new Intent(ctx, MainActivity.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx) .setSmallIcon(R.drawable.glyphicons_016_bin) // .setContentTitle(extras.getString("title")) .setContentTitle("fire for " + extras) .setStyle(new NotificationCompat.BigTextStyle().bigText("message")).setContentText("message") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:org.linphone.compatibility.ApiElevenPlus.java
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {//from w ww. j av a 2 s.co m NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(text) .setContentIntent(intent); Notification notif = notifBuilder.build(); notif.defaults |= Notification.DEFAULT_VIBRATE; notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_LIGHTS; return notif; }
From source file:com.parse.ParsePushUnityHelper.java
/** * A helper method that provides default behavior for handling ParsePushNotificationReceived. *//* w w w . ja va 2 s. co m*/ public static void handleParsePushNotificationReceived(Context context, String pushPayloadString) { try { JSONObject pushData = new JSONObject(pushPayloadString); if (pushData == null || (!pushData.has("alert") && !pushData.has("title"))) { return; } ManifestInfo info = new ManifestInfo(context); String title = pushData.optString("title", info.getDisplayName()); String alert = pushData.optString("alert", "Notification received."); String tickerText = title + ": " + alert; Random random = new Random(); int contentIntentRequestCode = random.nextInt(); Intent activityIntent = info.getLauncherIntent(); PendingIntent pContentIntent = PendingIntent.getActivity(context, contentIntentRequestCode, activityIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(alert).setTicker(tickerText).setSmallIcon(info.getPushIconId()) .setContentIntent(pContentIntent).setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL); Notification notification = builder.build(); NotificationManager manager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); int notificationId = (int) System.currentTimeMillis(); try { manager.notify(notificationId, notification); } catch (SecurityException se) { // Some phones throw exception for unapproved vibration. notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND; manager.notify(notificationId, notification); } } catch (JSONException e) { // Do nothing. } }
From source file:org.cesar.geofencesdemo.managers.NotificationsManager.java
/** * This notification it has to be launched when we enter or exit from a * location we've sepcified before in the {@link MainActivity} * /*w w w .j a v a 2 s. com*/ * @param geofence */ public void showLocationReminderNotification(final SimpleGeofence geofence) { mNotification = new NotificationCompat.Builder(mContext) .setTicker(mContext.getString(R.string.location_reminder_label)) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(mContext.getString(R.string.location_reminder_label)) .setContentText(geofence.getAddress()).setOnlyAlertOnce(true).setContentIntent(null).build(); mNotification.flags = Notification.FLAG_AUTO_CANCEL; mNotification.defaults |= Notification.DEFAULT_LIGHTS; mNotification.defaults |= Notification.DEFAULT_VIBRATE; mNotification.defaults |= Notification.DEFAULT_SOUND; // Launch notification mNotificationManager.notify(Integer.valueOf(geofence.getPlaceId()), mNotification); }
From source file:com.dimasdanz.kendalipintu.util.CommonUtilities.java
public static void generateNotification(Context context, String message, String time, String info) { try {//from ww w.j a v a2 s . c o m NotificationManager manager; int notificationID = 73; Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_notification); Notification.Builder builder = new Notification.Builder(context); Intent resultIntent = new Intent(context, LogActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(LogActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); Spannable sb = new SpannableString(message + " " + time + "-" + info); sb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, message.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setAutoCancel(true); builder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND); builder.setContentTitle(context.getString(R.string.notification_title)); builder.setContentText(sb); builder.setTicker(context.getString(R.string.notification_ticker)); builder.setNumber(++msgCounter); builder.setSmallIcon(R.drawable.ic_stat_notification); builder.setLargeIcon(largeIcon); builder.setContentIntent(resultPendingIntent); if (msgCounter > 1) { Notification.InboxStyle inboxStyle = new Notification.InboxStyle(); if (msgCounter > 6) { name[0] = new SpannableString("..."); name[1] = name[2]; name[2] = name[3]; name[3] = name[4]; name[4] = name[5]; name[5] = sb; } else { name[msgCounter - 1] = sb; } inboxStyle.setBigContentTitle(context.getString(R.string.notification_title)); inboxStyle.setSummaryText( msgCounter + " " + context.getString(R.string.notification_title) + " Baru"); for (int i = name.length; i > 0; i--) { inboxStyle.addLine(name[i - 1]); } builder.setStyle(inboxStyle); builder.setContentText(msgCounter + " " + context.getString(R.string.notification_title) + " Baru"); } else { name[0] = sb; } manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(notificationID, builder.build()); } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:com.fn.reunion.app.xmpp.Notifier.java
public void notify(String notificationId, String apiKey, String title, String message, String uri) { Log.d(LOGTAG, "notify()..."); Log.d(LOGTAG, "notificationId=" + notificationId); Log.d(LOGTAG, "notificationApiKey=" + apiKey); Log.d(LOGTAG, "notificationTitle=" + title); Log.d(LOGTAG, "notificationMessage=" + message); Log.d(LOGTAG, "notificationUri=" + uri); if (isNotificationEnabled()) { // Show the toast if (isNotificationToastEnabled()) { Toast.makeText(context, message, Toast.LENGTH_LONG).show(); }//from w w w .jav a 2s . c o m Notification notification = new Notification(); notification.icon = getNotificationIcon(); notification.defaults = Notification.DEFAULT_LIGHTS; if (isNotificationSoundEnabled()) { notification.defaults |= Notification.DEFAULT_SOUND; } if (isNotificationVibrateEnabled()) { notification.defaults |= Notification.DEFAULT_VIBRATE; } notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.when = System.currentTimeMillis(); notification.tickerText = message; Intent intent = new Intent(context, NotificationDetailsActivity.class); intent.putExtra(Constants.NOTIFICATION_ID, notificationId); intent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey); intent.putExtra(Constants.NOTIFICATION_TITLE, title); intent.putExtra(Constants.NOTIFICATION_MESSAGE, message); intent.putExtra(Constants.NOTIFICATION_URI, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); /* notification.setLatestEventInfo(context, notficationMessage , message , contentIntent); notificationManager.notify(Consts.NOTIFICATION_ID, notification);*/ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(getNotificationIcon()).setContentTitle("").setContentText(""); Notification n = mBuilder.setContentIntent(contentIntent).setSmallIcon(getNotificationIcon()) .setTicker("").setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(message.replaceAll("[\t\n\r]", "\n"))) .setContentText(message).build(); if (isNotificationSoundEnabled()) { n.defaults |= Notification.DEFAULT_SOUND; } if (isNotificationVibrateEnabled()) { n.defaults |= Notification.DEFAULT_VIBRATE; } notificationManager.notify(Consts.NOTIFICATION_ID, n); // Notification } else { Log.w(LOGTAG, "Notificaitons disabled."); } }
From source file:com.neal.repairer.ease.receiver.CallReceiver.java
@Override public void onReceive(Context context, Intent intent) { //username//from w ww .ja v a2s . c o m String from = intent.getStringExtra("from"); EMLog.d("CallReceiver", "app received a incoming call"); //????? if (isRunningForeground(context)) { context.startActivity(new Intent(context, VideoCallActivity.class).putExtra("username", from) .putExtra("isComingCall", true).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } else { // PendingIntentIntent???????activityPendingIntent,?Notification?Activity PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, VideoCallActivity.class).putExtra("username", from) .putExtra("isComingCall", true).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0); // Notification.Builder builder = new Notification.Builder(context); builder.setContentIntent(pendingIntent); builder.setSmallIcon(R.mipmap.ic_launcher_round); builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)); builder.setAutoCancel(true); builder.setTicker("???"); builder.setContentText("?"); builder.setContentTitle("?"); builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); //?? NotificationManager notificationManager = (NotificationManager) context .getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, builder.build()); } }
From source file:com.molice.oneingdufs.androidpn.Notifier.java
public void notify(String notificationId, String apiKey, String title, String message, String uri) { Log.d(LOGTAG, "notify()..."); Log.d(LOGTAG, "notificationId=" + notificationId); Log.d(LOGTAG, "notificationApiKey=" + apiKey); Log.d(LOGTAG, "notificationTitle=" + title); Log.d(LOGTAG, "notificationMessage=" + message); Log.d(LOGTAG, "notificationUri=" + uri); if (SettingsActivity.getNotificationEnabled(context)) { // Show the toast // if (isNotificationToastEnabled()) { // Toast.makeText(context, message, Toast.LENGTH_LONG).show(); // } // Notification Notification notification = new Notification(); notification.icon = getNotificationIcon(); // notification.defaults = Notification.DEFAULT_LIGHTS; if (SettingsActivity.getNotificationSound(context)) { notification.defaults |= Notification.DEFAULT_SOUND; }/*from w ww . j av a 2s. c o m*/ if (SettingsActivity.getNotificationVibrate(context)) { notification.defaults |= Notification.DEFAULT_VIBRATE; } notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.when = System.currentTimeMillis(); notification.tickerText = message; // Intent intent; // if (uri != null // && uri.length() > 0 // && (uri.startsWith("http:") || uri.startsWith("https:") // || uri.startsWith("tel:") || uri.startsWith("geo:"))) { // intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // } else { // String callbackActivityPackageName = sharedPrefs.getString( // Constants.CALLBACK_ACTIVITY_PACKAGE_NAME, ""); // String callbackActivityClassName = sharedPrefs.getString( // Constants.CALLBACK_ACTIVITY_CLASS_NAME, ""); // intent = new Intent().setClassName(callbackActivityPackageName, // callbackActivityClassName); // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); // } Intent intent = new Intent(context, MessageDetailActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); JSONObject data = formatMetaFromTitle(title); try { data.putOpt("id", notificationId); data.putOpt("content", message); } catch (Exception e) { Log.d("JSON", "Notifier#notify, e=" + e.toString()); } intent.putExtra("data", data.toString()); intent.putExtra("fromNotification", true); // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, random.nextInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, data.optString("title"), message, contentIntent); notificationManager.notify(random.nextInt(), notification); // Intent clickIntent = new Intent( // Constants.ACTION_NOTIFICATION_CLICKED); // clickIntent.putExtra(Constants.NOTIFICATION_ID, notificationId); // clickIntent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey); // clickIntent.putExtra(Constants.NOTIFICATION_TITLE, title); // clickIntent.putExtra(Constants.NOTIFICATION_MESSAGE, message); // clickIntent.putExtra(Constants.NOTIFICATION_URI, uri); // // positiveIntent.setData(Uri.parse((new StringBuilder( // // "notif://notification.adroidpn.org/")).append(apiKey).append( // // "/").append(System.currentTimeMillis()).toString())); // PendingIntent clickPendingIntent = PendingIntent.getBroadcast( // context, 0, clickIntent, 0); // // notification.setLatestEventInfo(context, title, message, // clickPendingIntent); // // Intent clearIntent = new Intent( // Constants.ACTION_NOTIFICATION_CLEARED); // clearIntent.putExtra(Constants.NOTIFICATION_ID, notificationId); // clearIntent.putExtra(Constants.NOTIFICATION_API_KEY, apiKey); // // negativeIntent.setData(Uri.parse((new StringBuilder( // // "notif://notification.adroidpn.org/")).append(apiKey).append( // // "/").append(System.currentTimeMillis()).toString())); // PendingIntent clearPendingIntent = PendingIntent.getBroadcast( // context, 0, clearIntent, 0); // notification.deleteIntent = clearPendingIntent; // // notificationManager.notify(random.nextInt(), notification); } else { Log.w(LOGTAG, "Notificaitons disabled."); } }
From source file:io.github.guaidaodl.pomodorotimer.utils.NotificationHelper.java
/** * Builds a notification to alert user to take a break after completed a tomato. *///www . ja v a2 s .com private static Notification buildNotificationForBreak(Context context) { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); return builder.setSmallIcon(R.drawable.ic_nofication) .setContentTitle(context.getString(R.string.notification_tomato_end_content_title)) .setContentText(context.getString(R.string.notification_tomato_end_content_text)) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE).setContentIntent(pi) .build(); }