List of usage examples for android.media RingtoneManager getDefaultUri
public static Uri getDefaultUri(int type)
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;//w ww. j av a2s .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. *///from w w w . j a v a 2 s . com 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 ww w. j a v a 2 s . c om*/ */ 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. *//* w w w. j a v a 2 s .c om*/ 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. *//*from www. j a va 2s . c o 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()); }
From source file:br.ajmarques.cordova.plugin.localnotification.Options.java
/** * Gibt den Pfad zum Sound der Notification an. *//*w w w . j a va 2 s . co m*/ public Uri getSound() { String sound = options.optString("sound", null); if (sound != null) { try { int soundId = (Integer) RingtoneManager.class.getDeclaredField(sound).get(Integer.class); return RingtoneManager.getDefaultUri(soundId); } catch (Exception e) { return Uri.parse(sound); } } return RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); }
From source file:com.foi.air1603.sport_manager.sevices.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from www . j av a 2 s . c om private void sendNotification(Map<String, String> messageBody) { Intent intent = new Intent(this, MainActivity.class); Bundle bundle = new Bundle(); bundle.putString("user", messageBody.get("user")); bundle.putString("reservation_id", messageBody.get("reservation_id")); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); // messageBody se sastoji od: user, reservation_id Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_event_white_48dp).setColor(getResources().getColor(R.color.green)) .setContentTitle("Novi invite!") .setContentText(messageBody.get("user") + " te pozvao u novi termin!").setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); if (MainActivity.user == null || MainActivity.user.hide_notifications == 0) { return; } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); // PAZI! nisam siguran je li se i MainActivity:handleSystemTrayNotification() koristi }
From source file:ca.justinrichard.link.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from w w w. java2 s . c om*/ private void sendNotification(String messageBody, String linkId) { Intent intent; if (linkId.equals("")) { intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } else { intent = new Intent(this, LinkActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(LINK_ID, linkId); } 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_link).setColor(getResources().getColor(R.color.colorPrimary)) .setContentTitle("Link request").setContentText(messageBody).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }