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.foi.air1603.sport_manager.sevices.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///w w w . java 2s. co m 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. *///www .j av a 2 s . c o m 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()); }
From source file:com.webonise.gardenIt.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from ww w . ja v a2 s. c om */ private void sendNotification(String id, String type, String message) { Intent intent = new Intent(this, GeneralDetailsActivity.class); if (type.equalsIgnoreCase(getString(R.string.notification_type_issue))) { intent.putExtra(Constants.BUNDLE_KEY_TYPE, Constants.TYPE_ADVICE); } else if (type.equalsIgnoreCase(getString(R.string.notification_type_request))) { intent.putExtra(Constants.BUNDLE_KEY_TYPE, Constants.TYPE_SERVICE); } intent.putExtra(Constants.BUNDLE_KEY_ID, Integer.parseInt(id)); 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_notification).setLargeIcon(getBitmapDrawable()) .setContentTitle(getString(R.string.app_name)).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.nghianh.giaitriviet.util.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param remoteMessage FCM remoteMessage *//*from ww w. j a v a2 s. c o m*/ private void sendNotification(RemoteMessage remoteMessage) { 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); String imageUri = remoteMessage.getData().get("image"); String message = remoteMessage.getData().get("message"); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setLargeIcon(getBitmapfromUrl(imageUri)).setSmallIcon(R.drawable.ic_launcher) .setContentTitle(remoteMessage.getNotification().getTitle()).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.kr.zenithcompany.MyGcmListenerService.java
private void sendNotification(String message, Bitmap bitmap) { Intent intent = new Intent(this, MainActivity.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) .setPriority(NotificationCompat.PRIORITY_MAX) .setContentTitle(getResources().getString(R.string.app_name)).setSmallIcon(R.mipmap.icon) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); if (bitmap != null) { NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(); style.setBigContentTitle(getString(R.string.app_name)); style.setSummaryText(message);//from ww w. j a v a 2 s. c o m style.bigPicture(bitmap); notificationBuilder.setStyle(style); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(UniqueID.getRandomNumber(1000), notificationBuilder.build()); }
From source file:com.UpTopApps.OilResetPro.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*w w w . j av a2s. com*/ private void sendNotification(String messageBody, String title) { Intent intent = new Intent(this, NotificationActivity.class); String text = ""; try { JSONObject obj = new JSONObject(messageBody); text = obj.getString("text"); } catch (JSONException e) { Log.d("jex", e.getMessage()); } intent.putExtra("body", text); 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_stat_ic_notification).setContentTitle(title).setContentText(text) .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.echopf.ECHOFcmListenerService.java
/** * Sets notification layouts./*from www . j a v a 2 s. co m*/ * @param data * @return NotificationCompat.Builder */ public NotificationCompat.Builder getNotificationBuilder(Bundle data) { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setAutoCancel(true); // get ApplicationInfo ApplicationInfo appInfo = null; String appName = null; try { appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); appName = getPackageManager() .getApplicationLabel(getPackageManager().getApplicationInfo(getPackageName(), 0)).toString(); } catch (NameNotFoundException e) { throw new RuntimeException(e); } // set title String title = (data.getString("title") != null) ? data.getString("title") : appName; notificationBuilder.setContentTitle(title); // set message if (data.getString("message") != null) notificationBuilder.setContentText(data.getString("message")); // set icon int manifestIco = appInfo.metaData.getInt(NOTIFICATION_ICON_KEY); int icon = (manifestIco != 0) ? manifestIco : appInfo.icon; notificationBuilder.setSmallIcon(icon); // set sound Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); notificationBuilder.setSound(defaultSoundUri); // set content intent String activity = appInfo.metaData.getString(PUSH_OPEN_ACTIVITY_KEY); if (activity != null) { try { Intent intent = new Intent(this, Class.forName(activity)).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .setComponent(new ComponentName(appInfo.packageName, activity)).putExtras(data); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); notificationBuilder.setContentIntent(pendingIntent); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } return notificationBuilder; }
From source file:br.ajmarques.cordova.plugin.localnotification.Options.java
/** * Gibt den Pfad zum Sound der Notification an. *///from w w w . jav a 2s . c o 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.yj.wangjatv.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param data GCM message received./* ww w . j a va2s . com*/ */ private void sendNotification(Bundle data) { Intent intent = new Intent(this, IntroActivity.class); intent.putExtra("data", data); 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(getString(R.string.app_name)) .setContentText(data.getString("msg")).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.afrolkin.samplepushclient.GCMIntentService.java
private static void generateNotification(Context context, String message) { int icon = R.mipmap.ic_announcement_black_48dp; long when = System.currentTimeMillis(); String title = context.getString(R.string.app_name); Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, "Push Message", when); notification.sound = soundUri;//from w ww . ja v a2s . com Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.putExtra("message", message); // Set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }