List of usage examples for android.app PendingIntent FLAG_ONE_SHOT
int FLAG_ONE_SHOT
To view the source code for android.app PendingIntent FLAG_ONE_SHOT.
Click Source Link
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 ww w . ja v a 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.// www . j av a2 s . c om */ 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./*from w w w . j av 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.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:kr.ds.say.MyFirebaseMessagingService.java
private void sendNotification(String message, Bitmap bitmap) { Intent intent = new Intent(this, IntroActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); String channelId = getString(R.string.channel_message_id); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.mipmap.icon) .setContentTitle(getString(R.string.app_name)).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 a2 s. co m*/ style.bigPicture(bitmap); notificationBuilder.setStyle(style); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // Since android Oreo notification channel is needed. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(channelId, getString(R.string.channel_message_id), NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(getString(R.string.channel_message)); notificationManager.createNotificationChannel(channel); } notificationManager.notify(UniqueID.getRandomNumber(1000), 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.//from www . j a va 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. *///from w w w.ja v a2 s . c o 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.//from w w w .j a v a2 s . 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.oasis.sdk.base.service.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from ww w. jav a 2s . com */ private void sendNotification(Bundle data) { Intent clickIntent = new Intent(this, com.oasis.sdk.base.communication.NotificationClickReceiver.class); //???? clickIntent.putExtras(data); int notificationID = (int) (System.currentTimeMillis() / 1000); PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), notificationID, clickIntent, PendingIntent.FLAG_ONE_SHOT); String message = data.getString("message"); String pkName = this.getPackageName(); PackageManager packageManager = this.getPackageManager(); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); ApplicationInfo applicationInfo = null; try { applicationInfo = packageManager.getApplicationInfo(pkName, 0); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); applicationInfo = getApplicationInfo(); } String applicationName = (String) packageManager.getApplicationLabel(applicationInfo); int appicon = applicationInfo.icon; NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle(); style.bigText(message); style.setBigContentTitle(applicationName); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(appicon).setContentTitle(applicationName).setContentText(message).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent).setStyle(style); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationID /* ID of notification */, notificationBuilder.build()); }
From source file:com.memetro.android.notifications.GcmBroadcastReceiver.java
private void sendNotification(String msg, Intent intent, Context context) { mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent newIntent = new Intent(context, SplashScreenActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, newIntent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.icon_push).setContentTitle("Memetro") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setAutoCancel(true) .setContentText(msg);/*from w w w. j a v a 2 s.c o m*/ mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); try { Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone r = RingtoneManager.getRingtone(context, notification); r.play(); } catch (Exception e) { e.printStackTrace(); } }
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 w ww . j ava 2s.c o 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()); }