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.korchid.msg.firebase.fcm.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from ww w.j a va 2 s.com private void sendNotification(String messageBody) { Log.d(TAG, "sendNotification"); 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.ic_logo).setContentTitle("FCM Message").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.sumang.chatdemo.MyFirebaseMessagingService.java
/** * Handle time allotted to BroadcastReceivers. *///from w w w . j ava 2 s . co m private void handleNow(String title, String messageBody) { Log.d(TAG, "Short lived task is done."); 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).setGroup("ABC") .setGroupSummary(true).setSmallIcon(R.drawable.messenger_bubble_small_white) .setColor(getResources().getColor(R.color.colorAccent)).setContentTitle(title) .setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext()); notificationManager.notify(Util.createID() /* ID of notification */, notificationBuilder.build()); }
From source file:com.ct.fitorto.gcm.GcmService.java
private void sendNotification(String msg, String title) { Intent intent = new Intent(this, NotificationActivity.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_stat_fitorto) .setLargeIcon((BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))) .setContentTitle(title).setContentText(msg).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); //manager.putPreferenceIntValues(ApplicationData.NOTIFICATION_ID, (notificationId + 1)); }
From source file:com.bevyios.gcm.BevyGcmListenerService.java
private void sendNotification(Bundle bundle) { Resources resources = getApplication().getResources(); String packageName = getApplication().getPackageName(); Class intentClass = getMainActivityClass(); if (intentClass == null) { return;/*from w w w . ja v a 2 s . c o m*/ } if (applicationIsRunning()) { Intent i = new Intent("BevyGCMReceiveNotification"); i.putExtra("bundle", bundle); sendBroadcast(i); return; } int resourceId = resources.getIdentifier(bundle.getString("largeIcon"), "mipmap", packageName); Intent intent = new Intent(this, intentClass); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); //Bitmap largeIcon = BitmapFactory.decodeResource(resources, resourceId); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) //.setLargeIcon(largeIcon) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("title").setContentText("content") .setAutoCancel(false).setSound(defaultSoundUri) //.setTicker(bundle.getString("ticker")) .setCategory(NotificationCompat.CATEGORY_CALL).setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setPriority(NotificationCompat.PRIORITY_HIGH).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notif = notificationBuilder.build(); notif.defaults |= Notification.DEFAULT_VIBRATE; notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_LIGHTS; notificationManager.notify(0, notif); }
From source file:com.anandroid.firebase.utils.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. */// w ww. ja va 2s .co m private void sendNotification(String messageBody) { Intent intent; if (messageBody.indexOf("F") == 0) { intent = new Intent(this, Analytics.class); } else { 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.mipmap.ic_launcher).setContentTitle("FCM Message").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:org.roman.findme.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww . j a v a2s . c o m */ private void sendNotification(String message) { Intent intent = new Intent(this, MessageActivity.class); intent.putExtra("message", message); 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.ic_stat_ic_notification).setContentTitle("Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); if (sharedPreferences.getBoolean("display_message", true)) { displayMessage(message); } }
From source file:com.entropy.promoenginedemoapp.gcm.MyGcmListenerService.java
private void sendNotification(String message) { Intent intent = new Intent(this, SecondActivity.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.logo).setContentTitle("Hype Demo").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify((int) System.currentTimeMillis() /* ID of notification */, notificationBuilder.build()); }
From source file:com.preguardia.app.notification.MyGcmListenerService.java
private void showConsultationApprovedNotification(String title, String message, String consultationId) { // Prepare intent which is triggered if the notification is selected Intent intent = new Intent(this, ConsultationDetailsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(Constants.EXTRA_CONSULTATION_ID, consultationId); PendingIntent pendingIntent = PendingIntent.getActivity(this, Constants.PATIENT_REQUEST_CODE, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_logo).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(4, notificationBuilder.build()); }
From source file:com.maryplasez.spicemeapp.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//* ww w . j av a2s. c o m*/ private void sendNotification(String messageBody) { String title = "I want to lick you till you swear allegiance to the empire"; Intent intent = new Intent(this, ChatActivity.class); intent.putExtra("PUSH", title); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 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.icon).setContentTitle(title).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.panamon.paccozz.fcm.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. */// w w w . j av a 2 s .co m private void sendNotification(String messageBody) { 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.ic_stat_ic_notification).setContentTitle("Paccozz") .setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }