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:at.wada811.utils.IntentUtils.java
/** * PendingIntent for OneShot Notification * * @param context/*ww w.j av a 2s . c o m*/ * @return */ public static PendingIntent createOneShotPendingIntent(Context context) { int requestCode = 0; // Private request code for the sender (currently not used). Intent intent = new Intent(); return PendingIntent.getActivity(context, requestCode, intent, PendingIntent.FLAG_ONE_SHOT); }
From source file:com.apptentive.android.example.push.MyGcmListenerService.java
@Override public void onMessageReceived(String from, Bundle data) { String title = data.getString("gcm.notification.title"); String body = data.getString("gcm.notification.body"); ApptentiveLog.e("From: " + from); ApptentiveLog.e("Title: " + title); ApptentiveLog.e("Body: " + body); Intent intent = new Intent(this, ExampleActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Apptentive.setPendingPushNotification(data); 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.notification).setContentTitle(title).setContentText(body) .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.jameswolfeoliver.pigeon.Managers.NotificationsManager.java
public static void createNotificationForRemoteLogin(String clientName, String clientIp) { Context context = PigeonApplication.getAppContext(); String summary = context.getString(R.string.connection_requested); String body = String.format(context.getString(R.string.user_connection_requested), clientName, clientIp); Intent confirmConnectionIntent = new Intent(context, ConnectionActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, confirmConnectionIntent, PendingIntent.FLAG_ONE_SHOT); Notification notification = getNotificationBuilder(context, context.getResources().getString(R.string.app_name), summary, body).setContentIntent(pendingIntent) .build();//from w w w. ja va2 s. c o m NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(REMOTE_CLIENT_TAG, REMOTE_CLIENT_ID, notification); }
From source file:com.survivingwithandroid.fpush.FireMsgService.java
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.d("Msg", "Message received [" + remoteMessage + "]"); // Create Notification Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410, intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_name).setContentTitle("Message") .setContentText(remoteMessage.getNotification().getBody()).setAutoCancel(true) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(1410, notificationBuilder.build()); }
From source file:hanuor.in.sil.MsgReceiver.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, 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(messageBody).setAutoCancel(false) .setSound(defaultSoundUri);/*w ww. j ava2 s. c o m*/ NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(1, notificationBuilder.build()); }
From source file:com.monkey.entonado.AlarmReciever.java
@Override public void onReceive(Context context, Intent intent) { System.out.println("llego a recieve ------------------"); // TODO Auto-generated method stub Intent in = new Intent(context, MainActivity.class); in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(context, 1994, in, PendingIntent.FLAG_ONE_SHOT); NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); NotificationCompat.Builder not = new NotificationCompat.Builder(context); not.setSmallIcon(android.R.drawable.ic_popup_sync).setAutoCancel(true) .setContentTitle("Ya han pasado 20 minutos").setContentText("Toca para pedir ms canciones") .setTicker("Ya puedes mandar canciones!").setContentIntent(pi); Notification noti = not.build(); noti.flags |= Notification.FLAG_ONGOING_EVENT; manager.notify(MainActivity.TAG, 0, noti); }
From source file:de.escoand.readdaily.PushMessageService.java
@Override public void onMessageReceived(final RemoteMessage remoteMessage) { RemoteMessage.Notification notification = remoteMessage.getNotification(); String title = getString(R.string.app_title); String message = ""; Intent intent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); LogHandler.log(Log.WARN, "received message"); // get title//from ww w. jav a2s . c om if (notification != null && notification.getTitle() != null && !notification.getTitle().isEmpty()) title = notification.getTitle(); // get message if (notification != null && notification.getBody() != null && !notification.getBody().isEmpty()) message = notification.getBody(); else if (remoteMessage.getData().containsKey("message")) message = remoteMessage.getData().get("message"); // build notification NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.icon_notification) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setContentTitle(title).setContentText(message).setAutoCancel(true) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentIntent(pendingIntent); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)) .notify((int) remoteMessage.getSentTime(), builder.build()); }
From source file:com.contactlab.clabpush_android_sample.GcmListenerService.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.notification_template_icon_bg).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.android.antitheft.util.AntiTheftNotifier.java
private static NotificationCompat.Builder createBaseContentBuilder(Context context) { Intent installIntent = new Intent(context, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 1, installIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); return new NotificationCompat.Builder(context).setWhen(System.currentTimeMillis()) .setContentIntent(contentIntent).setLocalOnly(true).setAutoCancel(true); }
From source file:com.bluros.updater.receiver.DownloadNotifier.java
private static NotificationCompat.Builder createBaseContentBuilder(Context context, Intent updateIntent) { PendingIntent contentIntent = PendingIntent.getActivity(context, 1, updateIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); return new NotificationCompat.Builder(context).setWhen(System.currentTimeMillis()) .setContentIntent(contentIntent).setLocalOnly(true).setAutoCancel(true); }