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:info.guardianproject.otr.app.im.service.StatusBarNotifier.java
private void setRinger(long providerId, NotificationCompat.Builder builder) { String ringtoneUri = getGlobalSettings().getRingtoneURI(); boolean vibrate = getGlobalSettings().getVibrate(); Uri sound = TextUtils.isEmpty(ringtoneUri) ? null : Uri.parse(ringtoneUri); builder.setSound(sound);// w ww.j a va 2s . c o m if (sound != null) { mLastSoundPlayedMs = SystemClock.elapsedRealtime(); } if (DBG) log("setRinger: notification.sound = " + sound); if (vibrate) { builder.setDefaults(Notification.DEFAULT_VIBRATE); if (DBG) log("setRinger: defaults |= vibrate"); } }
From source file:com.tweetlanes.android.service.BackgroundService.java
private Notification buildNotification(String message, int icon, Intent content_intent, Intent delete_intent) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setTicker(message);//from w w w . java 2 s .c om //builder.setContentTitle(getString(R.string.new_notifications)); builder.setContentTitle("New notifications"); builder.setContentText(message); builder.setAutoCancel(true); builder.setWhen(System.currentTimeMillis()); builder.setSmallIcon(icon); builder.setDeleteIntent( PendingIntent.getBroadcast(this, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setContentIntent( PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT)); int defaults = 0; //if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_SOUND, false)) { defaults |= Notification.DEFAULT_SOUND; //} //if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_VIBRATION, false)) { defaults |= Notification.DEFAULT_VIBRATE; //} //if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_LIGHTS, false)) { defaults |= Notification.DEFAULT_LIGHTS; //} builder.setDefaults(defaults); return builder.getNotification(); }
From source file:nu.firetech.android.pactrack.backend.ParcelUpdater.java
private void updateParcel(Bundle parcel, ParcelDbAdapter dbAdapter, NotificationManager notMgr) { Long rowId = parcel.getLong(ParcelDbAdapter.KEY_ROWID); String parcelId = parcel.getString(ParcelDbAdapter.KEY_PARCEL); Parcel parcelData = ParcelJsonParser.fetch(parcelId); mDbAdapter.updateParcelData(rowId, parcelData); if (parcelData.getParcel() != null) { parcelId = parcelData.getParcel(); }//from w ww . j av a 2s . c om int newEvents = 0; StringBuilder eventList = new StringBuilder(); for (ParcelEvent eventData : parcelData.getEvents()) { //loop through events if (mDbAdapter.addEvent(rowId, eventData)) { //if event was new if (newEvents > 0) { eventList.append("\n"); } eventList.append(eventData.toString()); newEvents++; } } if (newEvents > 0 && !mCtx.showsNews()) { Preferences prefs = Preferences.getPreferences(mAndroidCtx); //TODO Join existing notifications in some clever way... if (prefs.getNotificationEnabled()) { String parcelName = parcel.getString(ParcelDbAdapter.KEY_NAME); if (parcelName == null) { parcelName = mAndroidCtx.getString(R.string.generic_parcel_name, parcelId); } Intent intent = new Intent(mAndroidCtx, MainActivity.class).putExtra(ParcelDbAdapter.KEY_ROWID, rowId); PendingIntent contentIntent = PendingIntent.getActivity(mAndroidCtx, rowId.hashCode(), intent, 0); int stringId = (newEvents > 1 ? R.string.notification_ticker : R.string.notification_ticker_one); NotificationCompat.Builder n = new NotificationCompat.Builder(mAndroidCtx) .setSmallIcon(R.drawable.notification) .setTicker(mAndroidCtx.getString(stringId, parcelName)).setWhen(System.currentTimeMillis()) .setContentTitle(parcelName) .setContentText(newEvents == 1 ? eventList.toString() : mAndroidCtx.getString(R.string.notification_message, newEvents)) .setContentIntent(contentIntent).setSound(prefs.getNotificationSound()) .extend(new NotificationCompat.WearableExtender().setBackground(BitmapFactory .decodeResource(mAndroidCtx.getResources(), R.drawable.wearable_background))); if (newEvents > 1) { n.setStyle(new NotificationCompat.BigTextStyle().bigText(eventList.toString())); } if (prefs.getNotificationLight()) { n.setLights(prefs.getNotificationColor(), prefs.getNotificationOntime(), prefs.getNotificationOfftime()); } if (prefs.getNotificationVibrate()) { n.setDefaults(Notification.DEFAULT_VIBRATE); } notMgr.notify(rowId.hashCode(), n.build()); } } }
From source file:org.yaaic.irc.IRCService.java
/** * Update notification and vibrate and/or flash a LED light if needed * * @param text The ticker text to display * @param contentText The text to display in the notification dropdown * @param vibrate True if the device should vibrate, false otherwise * @param sound True if the device should make sound, false otherwise * @param light True if the device should flash a LED light, false otherwise *//*w w w .j av a2s. com*/ private void updateNotification(String text, String contentText, boolean vibrate, boolean sound, boolean light) { if (foreground) { Intent notifyIntent = new Intent(this, MainActivity.class); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notifyIntent, 0); if (contentText == null) { if (newMentions >= 1) { StringBuilder sb = new StringBuilder(); for (Conversation conv : mentions.values()) { sb.append(conv.getName() + " (" + conv.getNewMentions() + "), "); } contentText = getString(R.string.notification_mentions, sb.substring(0, sb.length() - 2)); } else if (!connectedServerTitles.isEmpty()) { StringBuilder sb = new StringBuilder(); for (String title : connectedServerTitles) { sb.append(title + ", "); } contentText = getString(R.string.notification_connected, sb.substring(0, sb.length() - 2)); } else { contentText = getString(R.string.notification_not_connected); } } notification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_notification) .setContentTitle(getText(R.string.app_name)).setContentText(contentText) .setContentIntent(contentIntent).setWhen(System.currentTimeMillis()) .setPriority(mentions.size() > 0 ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_MIN) .setCategory(NotificationCompat.CATEGORY_PROGRESS).build(); if (vibrate) { notification.defaults |= Notification.DEFAULT_VIBRATE; } if (sound) { notification.defaults |= Notification.DEFAULT_SOUND; } if (light) { notification.ledARGB = NOTIFICATION_LED_COLOR; notification.ledOnMS = NOTIFICATION_LED_ON_MS; notification.ledOffMS = NOTIFICATION_LED_OFF_MS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; } notification.number = newMentions; notificationManager.notify(FOREGROUND_NOTIFICATION, notification); } }
From source file:copytestapp.copytestapp.GCMIntentService.java
void notificationWithBigPicture(Context context, String title, String message, int icon, Bitmap banner, Class<?> activityClass, String eventPage, String ad_code, String ad_num) { Intent intent = new Intent(context, activityClass); intent.putExtra("adUrl", eventPage); intent.putExtra("adcodeNum", ad_code); intent.putExtra("ad_num", ad_num); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(icon) .setTicker(title).setContentTitle(title).setContentText("??? !") .setAutoCancel(true);//from w ww . ja v a 2 s . com NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(); style.setBigContentTitle(title); style.setSummaryText(message); style.bigPicture(banner); builder.setStyle(style); builder.setContentIntent(pendingIntent); builder.setDefaults(Notification.DEFAULT_VIBRATE); builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, builder.build()); }
From source file:com.shafiq.mytwittle.service.BackgroundService.java
private Notification buildNotification(String message, int icon, Intent content_intent, Intent delete_intent) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setTicker(message);/*from w w w. java2 s . com*/ // builder.setContentTitle(getString(R.string.new_notifications)); builder.setContentTitle("New notifications"); builder.setContentText(message); builder.setAutoCancel(true); builder.setWhen(System.currentTimeMillis()); builder.setSmallIcon(icon); builder.setDeleteIntent( PendingIntent.getBroadcast(this, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT)); builder.setContentIntent( PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT)); int defaults = 0; // if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_SOUND, // false)) { defaults |= Notification.DEFAULT_SOUND; // } // if // (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_VIBRATION, // false)) { defaults |= Notification.DEFAULT_VIBRATE; // } // if (mPreferences.getBoolean(PREFERENCE_KEY_NOTIFICATIONS_HAVE_LIGHTS, // false)) { defaults |= Notification.DEFAULT_LIGHTS; // } builder.setDefaults(defaults); return builder.getNotification(); }
From source file:com.inducesmile.androidtabwithswipe.RecoBackgroundMonitoringService.java
private void popupNotification(String msg) { Log.i("BackMonitoringService", "popupNotification()"); String currentTime = new SimpleDateFormat("HH:mm:ss", Locale.KOREA).format(new Date()); NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Intent intent = new Intent(RecoBackgroundMonitoringService.this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent content = PendingIntent.getActivity(RecoBackgroundMonitoringService.this, 0, intent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.o2) .setTicker("") .setContentTitle(" ? ? !") .setContentText(" ? .").setContentIntent(content) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(0xffffffff, 500, 500); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); builder.setStyle(inboxStyle);/*from w w w . j a v a 2s.c o m*/ nm.notify(mNotificationID, builder.build()); mNotificationID = (mNotificationID - 1) % 1000 + 9000; }
From source file:com.uphyca.idobata.android.service.IdobataService.java
private Notification buildNotification(PendingIntent pi, CharSequence title, CharSequence text) { int vibrate = mNotificationEffectsVibratePref.get() ? Notification.DEFAULT_VIBRATE : 0; int ledFlash = mNotificationEffectsLEDFlashPref.get() ? Notification.DEFAULT_LIGHTS : 0; int sound = mNotificationEffectsSoundPref.get() ? Notification.DEFAULT_SOUND : 0; NotificationCompat.Builder builder = new NotificationCompat.Builder(IdobataService.this) .setSmallIcon(R.drawable.ic_stat_notification).setContentTitle(title).setContentText(text) .setTicker(new StringBuilder(title).append(' ').append(text)).setAutoCancel(true) .setContentIntent(pi).setDefaults(vibrate | sound | ledFlash); if (ledFlash != 0) { builder.setLights(0xFF00FF00, 200, 1000); }/* w ww. ja va 2s .co m*/ return builder.build(); }
From source file:org.linphone.compatibility.ApiFivePlus.java
public static Notification createMessageNotification(Context context, String title, String msg, PendingIntent intent) {/* w w w . j a v a2 s .c o m*/ NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.chat_icon_over).setContentTitle(title).setContentText(msg) .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:org.awesomeapp.messenger.service.StatusBarNotifier.java
private void setRinger(long providerId, NotificationCompat.Builder builder) { Uri ringtoneUri = Preferences.getNotificationRingtoneUri(); builder.setSound(ringtoneUri);/*from w ww. j a v a2 s . c om*/ mLastSoundPlayedMs = SystemClock.elapsedRealtime(); if (DBG) log("setRinger: notification.sound = " + ringtoneUri); if (Preferences.getNotificationVibrate()) { builder.setDefaults(Notification.DEFAULT_VIBRATE); if (DBG) log("setRinger: defaults |= vibrate"); } }