List of usage examples for android.app Notification DEFAULT_VIBRATE
int DEFAULT_VIBRATE
To view the source code for android.app Notification DEFAULT_VIBRATE.
Click Source Link
From source file:com.google.samples.apps.iosched.ui.debug.actions.ShowSessionNotificationDebugAction.java
@Override public void run(Context context, Callback callback) { Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__")); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); Intent mapIntent = new Intent(context, UIUtils.getMapActivityClass(context)); mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); mapIntent.putExtra(BaseMapActivity.EXTRA_ROOM, "keynote"); PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); //= PendingIntent.getActivity(context, 0, mapIntent, 0); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setContentTitle("test notification").setContentText("yep, this is a test") .setTicker("hey, you got a test") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); notifBuilder.addAction(R.drawable.ic_map_holo_dark, context.getString(R.string.title_map), piMap); NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(/* ww w.ja v a2 s . co m*/ context.getResources().getQuantityString(R.plurals.session_notification_title, 1, 8, 1)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(32534, richNotification.build()); }
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;//w w w .j a v a 2 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.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} * /*ww w . j a va 2s .c om*/ * @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: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 w w w . ja v a 2 s . com*/ 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: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 ww w . j av a2s .co 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/* ww w . j a v a2 s.c om*/ 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.android.systemui.ReminderReceiver.java
@Override public void onReceive(final Context context, Intent intent) { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); SharedPreferences shared = context.getSharedPreferences(KEY_REMINDER_ACTION, Context.MODE_PRIVATE); if (intent.getBooleanExtra("clear", false)) { manager.cancel(NOTI_ID);//from w w w . jav a 2 s. c o m // User has set a new reminder but didn't clear // This notification until now if (!shared.getBoolean("updated", false)) { shared.edit().putBoolean("scheduled", false).commit(); shared.edit().putInt("hours", -1).commit(); shared.edit().putInt("minutes", -1).commit(); shared.edit().putInt("day", -1).commit(); shared.edit().putString("title", null).commit(); shared.edit().putString("message", null).commit(); } } else { String title = shared.getString("title", null); String message = shared.getString("message", null); if (title != null && message != null) { Bitmap bm = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_qs_alarm_on); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setTicker(title) .setContentTitle(title).setContentText(message).setAutoCancel(false).setOngoing(true) .setPriority(NotificationCompat.PRIORITY_HIGH).setSmallIcon(R.drawable.ic_qs_alarm_on) .setLargeIcon(bm).setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); int alertMode = Settings.System.getIntForUser(context.getContentResolver(), Settings.System.REMINDER_ALERT_NOTIFY, 0, UserHandle.USER_CURRENT); PendingIntent result = null; Intent serviceIntent = new Intent(context, ReminderService.class); if (alertMode != 0 && !QuietHoursHelper.inQuietHours(context, Settings.System.QUIET_HOURS_MUTE)) { context.startService(serviceIntent); } // Stop sound on click serviceIntent.putExtra("stopSelf", true); result = PendingIntent.getService(context, 1, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(result); // Add button for dismissal serviceIntent.putExtra("dismissNoti", true); result = PendingIntent.getService(context, 0, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.addAction(R.drawable.ic_sysbar_null, context.getResources().getString(R.string.quick_settings_reminder_noti_dismiss), result); // Add button for reminding later serviceIntent.putExtra("time", true); result = PendingIntent.getService(context, 2, serviceIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.addAction(R.drawable.ic_qs_alarm_on, context.getResources().getString(R.string.quick_settings_reminder_noti_later), result); shared.edit().putBoolean("scheduled", false).commit(); shared.edit().putInt("hours", -1).commit(); shared.edit().putInt("minutes", -1).commit(); shared.edit().putInt("day", -1).commit(); manager.notify(NOTI_ID, builder.build()); } } shared.edit().putBoolean("updated", false).commit(); }
From source file:io.github.guaidaodl.pomodorotimer.utils.NotificationHelper.java
/** * Builds a notification to alert user to take a break after completed a tomato. *///from ww w . j a v a 2 s . c o m 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(); }
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 ww w . ja va 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:org.androidpn.client.Notifier.java
public void notify(String notificationId, String apiKey, String title, String message, String uri, String imageUrl) {//from w w w .jav a2 s. c om 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(); } mBuilder.setWhen(System.currentTimeMillis())//? .setPriority(Notification.PRIORITY_DEFAULT)// // .setAutoCancel(true)//????? .setOngoing(false)//ture???,??(?)???,?(,??,) .setDefaults(Notification.DEFAULT_VIBRATE)//???????defaults?? //Notification.DEFAULT_ALL Notification.DEFAULT_SOUND // requires VIBRATE permission .setSmallIcon(getNotificationIcon()); mBuilder.setAutoCancel(true)//? .setContentTitle(title).setContentText(message).setTicker(message); // Notification if (isNotificationSoundEnabled()) { mBuilder.setDefaults(Notification.DEFAULT_SOUND); } if (isNotificationVibrateEnabled()) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } mBuilder.setOnlyAlertOnce(true); // 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, 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.putExtra(Constants.NOTIFICATION_IMAGE_URL, imageUrl); 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); mBuilder.setContentIntent(contentIntent); notificationManager.notify(random.nextInt(), mBuilder.build()); } else { Log.w(LOGTAG, "Notificaitons disabled."); } }