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:org.onepf.opfpush.pushsample.util.NotificationUtils.java
public static void showNotification(@NonNull final Context context, @NonNull final String notificationTitle, @NonNull final String notificationText) { OPFLog.logMethod(context, notificationTitle, notificationText); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, DemoActivity.class), 0); final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.notification_icon).setContentTitle(notificationTitle) .setContentText(notificationText).setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND) .setContentIntent(pendingIntent); ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(NOTIFICATION_ID.getAndIncrement(), notificationBuilder.build()); }
From source file:org.onepf.opfpush.unity.util.NotificationUtils.java
public static void showNotification(@NonNull final Context context, @NonNull final String notificationTitle, @NonNull final String notificationText) { OPFLog.logMethod(NotificationUtils.class, "showNotification", context, notificationTitle, notificationText); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, UnityPlayerNativeActivity.class), 0); final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(android.R.drawable.ic_notification_overlay).setContentTitle(notificationTitle) .setContentText(notificationText).setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND) .setContentIntent(pendingIntent); ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(NOTIFICATION_ID.getAndIncrement(), notificationBuilder.build()); }
From source file:gcm.GcmMessageHandler.java
private void createNotification(String title, String body) { Context context = getBaseContext(); int defaults = 0; defaults = defaults | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_AUTO_CANCEL; Intent notificationIntent = new Intent(context, ConversationActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIndent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(body) .setDefaults(defaults).setStyle(new NotificationCompat.BigTextStyle().bigText(body)) .setContentIntent(contentIndent).setAutoCancel(true); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build()); }
From source file:es.ugr.swad.swadroid.gui.AlertNotificationFactory.java
public static NotificationCompat.Builder createAlertNotificationBuilder(Context context, String contentTitle, String contentText, String ticker, PendingIntent pendingIntent, int smallIcon, int largeIcon, boolean alertSignals, boolean autocancel, boolean ongoing, boolean onlyAlertOnce) { int flags = 0; NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context).setAutoCancel(autocancel) .setSmallIcon(smallIcon)/* w ww. j a va 2s .co m*/ .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), largeIcon)) .setContentTitle(contentTitle).setContentText(contentText).setTicker(ticker).setOngoing(ongoing) .setOnlyAlertOnce(onlyAlertOnce).setWhen(System.currentTimeMillis()); //.setLights(Color.GREEN, 500, 500); //Launch activity on alert click if (pendingIntent != null) { notifBuilder.setContentIntent(pendingIntent); } //Add sound, vibration and lights if (alertSignals) { if (Preferences.isNotifSoundEnabled()) { flags |= Notification.DEFAULT_SOUND; } else { notifBuilder.setSound(null); } if (Preferences.isNotifVibrateEnabled()) { flags |= Notification.DEFAULT_VIBRATE; } if (Preferences.isNotifLightsEnabled()) { flags |= Notification.DEFAULT_LIGHTS; } } notifBuilder.setDefaults(flags); return notifBuilder; }
From source file:org.linphone.compatibility.ApiElevenPlus.java
@SuppressWarnings("deprecation") public static Notification createMessageNotification(Context context, int msgCount, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) { String title;/*from www .jav a 2s. c om*/ if (msgCount == 1) { title = msgSender; } else { title = context.getString(R.string.unread_messages).replace("%i", String.valueOf(msgCount)); } Notification notif = new Notification.Builder(context).setContentTitle(title).setContentText(msg) .setContentIntent(intent).setSmallIcon(R.drawable.chat_icon_over).setAutoCancel(true) .setDefaults( Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setWhen(System.currentTimeMillis()).setLargeIcon(contactIcon).getNotification(); return notif; }
From source file:es.ugr.swad.swadroid.gui.AlertNotification.java
public static void alertNotif(Context context, int notifAlertId, String contentTitle, String contentText, String ticker, Intent activity) { //Obtain a reference to the notification service String ns = Context.NOTIFICATION_SERVICE; NotificationManager notifManager = (NotificationManager) context.getSystemService(ns); //Configure the alert int defaults = 0; NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context).setAutoCancel(true) .setSmallIcon(R.drawable.ic_launcher_swadroid) .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher_swadroid)) .setContentTitle(contentTitle).setContentText(contentText).setTicker(ticker) .setWhen(System.currentTimeMillis()); //.setLights(Color.GREEN, 500, 500); //Launch activity on alert click if (activity != null) { PendingIntent notificationsPendingIntent = PendingIntent.getActivity(context, 0, activity, Intent.FLAG_ACTIVITY_NEW_TASK); notifBuilder.setContentIntent(notificationsPendingIntent); }//from ww w . j a va2s . co m //Add sound, vibration and lights if (Preferences.isNotifSoundEnabled()) { defaults |= Notification.DEFAULT_SOUND; } else { notifBuilder.setSound(null); } if (Preferences.isNotifVibrateEnabled()) { defaults |= Notification.DEFAULT_VIBRATE; } if (Preferences.isNotifLightsEnabled()) { defaults |= Notification.DEFAULT_LIGHTS; } notifBuilder.setDefaults(defaults); //Create alert Notification notif = notifBuilder.build(); //Send alert notifManager.notify(notifAlertId, notif); }
From source file:fr.paug.droidcon.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); //= 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); NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(//from w w w. j av a2s . c o 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:com.codemobiles.util.CMNotification.java
public static void notify(final Context ctx, final int iconResID, final String remote_image_url, final String title, final String desc, final Class<?> receiver) { final Handler handler = new Handler(); new Thread(new Runnable() { @Override/*w w w .ja va2 s . c om*/ public void run() { try { remote_picture = BitmapFactory .decodeStream((InputStream) new URL(remote_image_url).getContent()); // remote_picture = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.ic_launcher); } catch (IOException e) { e.printStackTrace(); } handler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub mNotificationManager = (NotificationManager) ctx .getSystemService(Context.NOTIFICATION_SERVICE); Notification noti = setNormalNotification(ctx, iconResID, remote_picture, title, desc, receiver); // Notification noti = setBigTextStyleNotification(ctx); noti.defaults |= Notification.DEFAULT_LIGHTS; noti.defaults |= Notification.DEFAULT_VIBRATE; noti.defaults |= Notification.DEFAULT_SOUND; noti.defaults |= Notification.FLAG_AUTO_CANCEL; noti.flags |= Notification.FLAG_ONLY_ALERT_ONCE; final int notificationID = new Random().nextInt(); noti.when = System.currentTimeMillis() + 1000 * 60; mNotificationManager.notify(notificationID, noti); } }); } }).start(); }
From source file:com.commonsware.android.eventbus.greenrobot.ScheduledService.java
public void onEvent(RandomEvent event) { NotificationCompat.Builder b = new NotificationCompat.Builder(this); Intent ui = new Intent(this, EventDemoActivity.class); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND) .setContentTitle(getString(R.string.notif_title)).setContentText(Integer.toHexString(event.value)) .setSmallIcon(android.R.drawable.stat_notify_more).setTicker(getString(R.string.notif_title)) .setContentIntent(PendingIntent.getActivity(this, 0, ui, 0)); NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mgr.notify(NOTIFY_ID, b.build());//from www. j a v a2 s.co m }
From source file:com.commonsware.android.eventbus.lbm.ScheduledService.java
@Override protected void doWakefulWork(Intent intent) { Intent event = new Intent(EventLogFragment.ACTION_EVENT); long now = Calendar.getInstance().getTimeInMillis(); int random = rng.nextInt(); event.putExtra(EventLogFragment.EXTRA_RANDOM, random); event.putExtra(EventLogFragment.EXTRA_TIME, now); if (!LocalBroadcastManager.getInstance(this).sendBroadcast(event)) { NotificationCompat.Builder b = new NotificationCompat.Builder(this); Intent ui = new Intent(this, EventDemoActivity.class); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND) .setContentTitle(getString(R.string.notif_title)).setContentText(Integer.toHexString(random)) .setSmallIcon(android.R.drawable.stat_notify_more).setTicker(getString(R.string.notif_title)) .setContentIntent(PendingIntent.getActivity(this, 0, ui, 0)); NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mgr.notify(NOTIFY_ID, b.build()); }//w w w . j av a 2 s . co m }