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:kr.ds.humor.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// ww w . j a v a 2 s. c o m */ private void sendNotification(String message) { Intent intent = new Intent(this, IntroActivity.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) .setContentTitle(getResources().getString(R.string.app_name)).setSmallIcon(R.mipmap.icon) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(UniqueID.getRandomNumber(1000), notificationBuilder.build()); }
From source file:com.jameswolfeoliver.pigeon.Managers.NotificationsManager.java
public static void createNotificationForMessageReceived(Context context, Conversation conversation, Message message, Contact contact) { String summary = String.format(context.getString(R.string.message_notification_summary), contact.getName(), message.getBody());//w w w. j av a2 s. co m Intent conversationIntent = new Intent(context, ConversationActivity.class); conversationIntent.putExtra(ConversationActivity.CONVERSATION_EXTRA, conversation); String replyLabel = context.getString(R.string.message_reply); RemoteInput remoteInput = new RemoteInput.Builder(MessageReplyService.MESSAGE_TEXT_KEY).setLabel(replyLabel) .build(); Intent replyIntent = new Intent(context, MessageReplyService.class); replyIntent.putExtra(MessageReplyService.CONVERSATION_KEY, conversation); PendingIntent replyPendingIntent = PendingIntent.getService(context, 0, replyIntent, 0); NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_sms, context.getString(R.string.message_reply), replyPendingIntent).addRemoteInput(remoteInput).build(); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, conversationIntent, PendingIntent.FLAG_ONE_SHOT); Notification notification = getNotificationBuilder(context, contact.getName(), summary, message.getBody()) .setContentIntent(pendingIntent).addAction(replyAction).build(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(CONVERSATION_TAG, conversation.getThreadId(), notification); }
From source file:com.parttime.activity.BaseActivity.java
/** * ???????????/*from w w w .ja v a2 s.c o m*/ * ???? * @param message */ protected void notifyNewMessage(EMMessage message) { //????(app??demo??) //?setShowNotificationInbackgroup:false(false???sdk??) if (!EasyUtils.isAppRunningForeground(this)) { return; } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(getApplicationInfo().icon).setWhen(System.currentTimeMillis()).setAutoCancel(true); String ticker = CommonUtils.getMessageDigest(message, this); if (message.getType() == Type.TXT) ticker = ticker.replaceAll("\\[.{2,3}\\]", "[]"); //???? mBuilder.setTicker(message.getFrom() + ": " + ticker); //pendingintent?2.3bug Intent intent = new Intent(this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, notifiId, intent, PendingIntent.FLAG_ONE_SHOT); mBuilder.setContentIntent(pendingIntent); Notification notification = mBuilder.build(); notificationManager.notify(notifiId, notification); notificationManager.cancel(notifiId); }
From source file:com.excilys.voisinsenor.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// ww w .j a v a 2s .c om */ private void sendNotification(String message) { Intent intent = new Intent(this, HomeActivity.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()); }
From source file:com.derekma.videogallery.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w ww .j av a 2 s . co m*/ */ private void sendNotification(String message, String id, String title) { Intent intent = new Intent(this, PlayerActivity.class); intent.putExtra("videoId", id); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); /** * Different type of PendingIntent * FLAG_CANCEL_CURRENT * FLAG_NO_CREATE * FLAG_ONE_SHOT * FLAG_UPDATE_CURRENT */ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Bitmap btm = BitmapFactory.decodeResource(getResources(), R.drawable.paw_heart); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.paw_heart_small).setContentTitle(title).setContentText(message) .setAutoCancel(true).setLargeIcon(btm).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.versul.newbornswatcher.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww .j a va2 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 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.eye); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(android.R.drawable.ic_dialog_alert) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_large)) .setContentTitle("Newborns Watcher").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.example.prueba.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*w w w . ja va 2 s .co m*/ */ private void sendNotification(String message, String user, String time, String men, String hr) { Intent intent = new Intent(this, Confirmacion.class); intent.putExtra("user", user); intent.putExtra("time", time); intent.putExtra("hr", hr); 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.book).setContentTitle("Biblioteca").setContentText(men).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:azzaoui.sociadee.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from ww w .j av a 2 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.pp_swag).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.rajat.e_subzi.gcm.MyGcmListenerService.java
private void sendNotification(String message) { Intent intent = new Intent(this, NotificationView.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.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); // bigText.bigText(message); // bigText.setBigContentTitle("eSubzi"); //bigText.setSummaryText("By: Dhaval Sodha Parmar"); // RemoteViews remoteViews = new RemoteViews(getPackageName(), // R.layout.custom_notification); // Intent resultIntent = new Intent(this, Login.class); // // The stack builder object will contain an artificial back stack for // // the // // started Activity. // // This ensures that navigating backward from the Activity leads out of // // your application to the Home screen. // TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // // Adds the back stack for the Intent (but not the Intent itself) // stackBuilder.addParentStack(Login.class); // // Adds the Intent that starts the Activity to the top of the stack // stackBuilder.addNextIntent(resultIntent); /////////////////////// NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.bag).setContentTitle("eSubzi").setContentText(message) //.setContent() .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); //notificationBuilder.setStyle(bigText); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(id++, notificationBuilder.build()); }
From source file:io.autem.AutemGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww. j a v a 2 s . 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) .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()); }