List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION
int TYPE_NOTIFICATION
To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.
Click Source Link
From source file:com.andrewchelladurai.simplebible.utilities.NotificationDisplayer.java
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive: called"); long when = System.currentTimeMillis(); int MID = (int) when; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent notIntent = new Intent(context, SimpleBibleActivity.class); notIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notIntent, PendingIntent.FLAG_UPDATE_CURRENT); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notification_small_icon) .setContentTitle(context.getString(R.string.application_name)) .setContentText(context.getString(R.string.notification_text)).setSound(alarmSound) .setAutoCancel(true).setWhen(when).setContentIntent(pendingIntent); notificationManager.notify(MID, builder.build()); Log.d(TAG, "onReceive: reminder Created"); }
From source file:com.vncreatures.customItems.wakefulservice.AppService.java
private void updateNotification() { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String userId = pref.getString(Common.USER_ID, null); HrmService service = new HrmService(); if (userId != null) { service.requestGetNotification(userId); service.setCallback(new ThreadTaskCallback() { @Override// ww w. ja v a2s . c o m public void onSuccess(ThreadModel threadModel) { int count = threadModel.countAllNotification(); if (count > 0) { Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alarmSound == null) { alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); if (alarmSound == null) { alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); } } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( getApplicationContext()).setSmallIcon(R.drawable.vnc_icon) .setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.notification_overall, count)) .setSound(alarmSound).setAutoCancel(true); // Creates an explicit intent for an Activity in your // app Intent resultIntent = new Intent(getApplicationContext(), LoginActivity.class); // The stack builder object will contain an artificial // back // stack for the // started Activity. // This ensures that navigating backward from the // Activity // leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext()); // Adds the back stack for the Intent (but not the // Intent // itself) stackBuilder.addParentStack(LoginActivity.class); // Adds the Intent that starts the Activity to the top // of // the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(Common.COMMON_ID, mBuilder.build()); } } @Override public void onError() { } }); } }
From source file:com.demo.instantpush.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w ww . j a v a 2s . c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, RequestActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("GCM Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:com.example.paul.greenpooling11.MyFirebaseMessagingService.java
private void sendNotification(String messageBody) { Intent intent = new Intent(this, TripRequestPage.class); intent.putExtra("tripId", tripId); intent.putExtra("passengerId", passengerId); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Trip Request").setContentText(messageBody) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.achep.acdisplay.ui.activities.MainActivity.java
private static void sendTestNotification(@NonNull Context context) { final int id = App.ID_NOTIFY_TEST; final Resources res = context.getResources(); PendingIntent pendingIntent = PendingIntent.getActivity(context, id, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle() .bigText(res.getString(R.string.notification_test_message_large)); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_test_message)).setContentIntent(pendingIntent) .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher)) .setSmallIcon(R.drawable.stat_acdisplay).setAutoCancel(true).setStyle(bts) .setColor(App.ACCENT_COLOR)/* w w w .ja va2 s. com*/ .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(id, builder.build()); }
From source file:biz.atelecom.communicator.MyGcmListenerService.java
private void sendNotification(Bundle data) { //Intent intent = new Intent(this, ChatActivity.class); Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(data);// ww w . ja v a2 s . co m PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.atelecom_ic_notification).setContentTitle("Atelecom Message") .setContentText("message").setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.unfc.choicecustomercaretb.gcmservices.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM * message.// www.j a v a 2s . c o m * * @param message * GCM message received. */ private void sendNotification(String message) { Intent intent = new Intent(this, HomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.app_icon).setContentTitle("Your request has been accepted!!") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify((int) new Date().getTime(), notificationBuilder.build()); }
From source file:com.syncano.gcmsample.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// www.j a v a 2s . co m */ private void showNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon).setContentTitle(getString(R.string.notification_title)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.bullmobi.message.ui.activities.MainActivity.java
private static void sendTestNotification(@NonNull Context context) { final int id = App.ID_NOTIFY_TEST; final Resources res = context.getResources(); PendingIntent pendingIntent = PendingIntent.getActivity(context, id, new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle() .bigText(res.getString(R.string.notification_test_message_large)); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(res.getString(R.string.app_name)) .setContentText(res.getString(R.string.notification_test_message)).setContentIntent(pendingIntent) .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher)) .setSmallIcon(R.drawable.stat_easynotification).setAutoCancel(true).setStyle(bts) .setColor(App.ACCENT_COLOR)/*from w w w. j a v a2 s.c om*/ .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(id, builder.build()); }
From source file:com.example.fiveguys.trip_buddy_v0.fcm.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. *///from ww w . j a va 2s .c om public static void sendNotification(Context context, String messageBody, String channelUrl) { Intent intent = new Intent(context, com.example.fiveguys.trip_buddy_v0.main.ChatActivity.class); intent.putExtra("groupChannelUrl", channelUrl); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 /* Request code */, intent, PendingIntent.FLAG_UPDATE_CURRENT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(context.getResources().getString(R.string.app_name)).setContentText(messageBody) .setAutoCancel(true).setSound(defaultSoundUri).setPriority(Notification.PRIORITY_MAX) .setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }