List of usage examples for android.media RingtoneManager getDefaultUri
public static Uri getDefaultUri(int type)
From source file:com.services.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// w w w .ja v a 2s . co m */ private void sendNotification(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) .setContentTitle("HihgSpeet").setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); //Log that something was recived Log.d("NOTIFY", "sendNotification(String message) was called with msg: " + message); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.gaurav.myreminder.PushNotification.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from w w w .j a va 2 s .c o m*/ private void sendNotification(String messageBody) { Intent intent = new Intent(this, HomeScreen.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.gm_old).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.kalis.cloudmessaging.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w ww.jav a2 s . c o m*/ */ private void sendNotification(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.ic_favorite).setContentTitle("GCM 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.uriel.myapplication.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// w w w .ja v a 2 s . c o m */ private void sendNotification(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.ism).setContentTitle("International School of Monaco") .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.sergeymild.allychat.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w w w .j a v a 2 s . c o m*/ */ private void sendNotification(String message) { PushModel pushModel = new Gson().fromJson(message, PushModel.class); Intent intent = new Intent(this, RoomsActivity.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("Demo App Push") .setContentText(pushModel.getMessage()).setNumber(pushModel.getUnreadCount()).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:assistance.shopping.msc.assistant.support.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message shoppingBroadcastDescription received. *//* w w w . j ava2 s . co m*/ private void sendNotification(String messageBody) { Intent intent = new Intent(this, LoginActivity.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("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.velvetcase.app.material.util.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//ww w . java 2s . c o m */ private void sendNotification(String message, String title) { Intent intent = new Intent(this, SplashScreenActivity.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.not_icon).setContentTitle(message).setContentText(title) .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.jenky.codebuddy.services.FBMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param message FCM message body received. *///from www. ja v a 2 s .co m private void sendNotification(ArrayMap<String, String> message) { Intent intent = IntentFactory.getMainIntent(this); 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); long[] vibrate = { Long.parseLong(message.get("vibrate")), Long.parseLong(message.get("vibrate")) }; NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notification).setContentTitle(message.get("title")) .setContentText(message.get("message")).setSound(defaultSoundUri).setVibrate(vibrate) .setContentIntent(pendingIntent) .setStyle(new NotificationCompat.BigTextStyle().bigText(message.get("content"))) .setLights(Color.parseColor(message.get("colour")), 500, 500); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:com.med_presc_pat.Utilities.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from w ww.j av a 2s.c om private void sendNotification(String messageBody) { Intent intent = new Intent(this, NotificationActionService.class).setAction(ACTION_1); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getService(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_ic_notification).setContentTitle("Medical") .setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri) .addAction(R.drawable.common_google_signin_btn_icon_dark, "Accept", pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.example.android.alarmclock.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from www. j av a 2 s .c om*/ */ private void sendNotification(String message) { Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); 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("GCM Message") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }