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.sqldexter.gcmnetworking.MyGcmListenerService.java
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) .setColor(Color.parseColor("#e65100")).setSmallIcon(R.drawable.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()); }
From source file:com.votzapp.app.MyGcmListenerService.java
/** * Called when message is received.//from ww w. j a v a 2s .co m * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] //And show mobile notification @Override public void onMessageReceived(String from, Bundle data) { String body = data.getString("body"); String title = data.getString("title"); 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); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(title).setContentText(body) .setSound(defaultSoundUri).setContentIntent(pendingIntent); notificationManager.notify(1, mBuilder.build()); }
From source file:com.ce.skuniv.helpers.Notifications.java
public void displayNotification(String title, String text, boolean Sound, int Id, boolean isPresistant) { if (Id == 0) { Id = rnd.nextInt();//from w ww .j a va 2 s. com } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_icon).setContentTitle(title).setContentText(text); if (Sound) mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); // mBuilder.setOnlyAlertOnce(false); mBuilder.setTicker(title + ":" + text); mBuilder.setOngoing(isPresistant); mBuilder.setAutoCancel(true); // Intent notificationIntent = new Intent(context, // MainMultiWiiActivity.class); Intent notificationIntent = new Intent(context, MainMultiWiiActivity.class); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // You // need this if starting // the activity from a service notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(contentIntent); // mNotificationManager.notify(Id, mBuilder.build()); }
From source file:com.ezio.multiwii.helpers.Notifications.java
public void displayNotification(String title, String text, boolean Sound, int Id, boolean isPresistant) { if (Id == 0) { Id = rnd.nextInt();//from ww w. j a v a 2 s. c om } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_stat_icon).setContentTitle(title).setContentText(text); if (Sound) mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); // mBuilder.setOnlyAlertOnce(false); mBuilder.setTicker(title + ":" + text); mBuilder.setOngoing(isPresistant); mBuilder.setAutoCancel(true); // Intent notificationIntent = new Intent(context, // MainMultiWiiActivity.class); Intent notificationIntent = new Intent(context, MainMultiWiiActivity.class); // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // You // need this if starting // the activity from a service notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(Id, mBuilder.build()); }
From source file:br.org.projeto.vigilante.push.MyGcmListenerService.java
private void sendNotification(String message) { Intent intent = MainActivity_.intent(this).get(); 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) .setContentTitle(getString(R.string.app_name)).setSmallIcon(R.drawable.ic_stat_action_account_child) .setColor(getResources().getColor(R.color.colorPrimary)) .setStyle(new NotificationCompat.BigTextStyle().bigText(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.umanji.umanjiapp.gcm.GcmListenerService.java
private void sendNotification(Bundle data) { String title = data.getString("title"); String text = data.getString("text"); Intent intent = new Intent(this, MainActivity.class); intent.putExtra("bundle", 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.drawable.ic_umanji_launcher).setContentTitle(title).setContentText(text) .setAutoCancel(true)/*from www. j a va 2s. co m*/ // .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.takeoffandroid.GCMDemo.GCMPushNotification.GCMListenerService.java
/** * Create and show a simple notification containing the received GCM message. * /*w ww . j a v a 2s.c o m*/ * @param message GCM message received. */ 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.gcm_logo).setContentTitle("Takeoff Android").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.owncloud.android.services.firebase.NCFirebaseMessagingService.java
private void sendNotification(String contentTitle) { Intent intent = new Intent(this, NotificationsActivity.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.mipmap.ic_launcher).setContentTitle(contentTitle).setSound(defaultSoundUri) .setAutoCancel(true).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:com.google.firebase.codelab.friendlychat.MyFirebaseMessagingService.java
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_account_circle_black_36dp).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.sevenre.trackre.parent.gcm.MyGcmListenerService.java
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_cast_light).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()); }