TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(FieldAgent.class); stackBuilder.addNextIntent(intent); PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher).setContent( remoteViews); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, test.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(test.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.button1, resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(100, mBuilder.build());
if (Build.VERSION.SDK_INT >= 16) { TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(cls); stackBuilder.addNextIntent(activityIntent); stackBuilder.startActivities(); } else {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setContentTitle("Test notification").setContentText("this is test application.").setSmallIcon(R.drawable.ic_launcher); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addNextIntent(new Intent(this, MainActivity.class)); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, builder.build());
.addParentStack(MainActivity.class) .addNextIntent(new Intent(ctx, MainActivity.class)); .build(); manager.notify(ERROR_NOTIFICATION_ID, notification);
Intent intent = new Intent(context, MatchActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent stackBuilder.addNextIntentWithParentStack(new Intent(context, MainActivity.class)); stackBuilder.addNextIntent(intent); PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); Intent intent1 = new Intent(context, HomeActivity.class); stackBuilder.addNextIntent(intent1); Uri uriUrl = Uri.parse(link); Intent intent2 = new Intent(Intent.ACTION_VIEW, uriUrl); stackBuilder.addNextIntent(intent2); PendintIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(notificationIntent); .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationManager.notify(0, builder.build());
private void createNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle("New beacon in range") .setContentText("You are currently in the range of a new beacon.") .setSmallIcon(R.drawable.ic_launcher); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addNextIntent(new Intent(context, MainActivity.class)); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); builder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, builder.build()); }
stackBuilder.addParentStack(FreesmsLog.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this); taskStackBuilder.addParentStack(Agenda.class); // Difference is in this line //add resultIntent to top of the stack taskStackBuilder.addNextIntent(resultIntent);
// Creates an explicit intent for an ResultActivity to receive. Intent resultIntent = new Intent(Fragmentz.ctx, NotificationReceiverActivity.class); // This ensures that the back button follows the recommended convention for the back key. TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
... Intent resultIntent = new Intent(this, ResultActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack stackBuilder.addParentStack(ResultActivity.class); // Adds the Intent to the top of the stack stackBuilder.addNextIntent(resultIntent); // Gets a PendingIntent containing the entire back stack PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); ... NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(id, builder.build());
@Override public void didEnterRegion(Region arg0) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setContentTitle("Beacon Reference Application") .setContentText("A beacon is nearby.") .setSmallIcon(R.drawable.ic_launcher); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addNextIntent(new Intent(this, MonitoringActivity.class)); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); builder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, builder.build()); }
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MyActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); mBuilder.setContentIntent(resultPendingIntent);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(Activity_One.class); stackBuilder.addNextIntent(resultIntent);
Intent resultIntent = new Intent(this, SecondActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // All the parents of SecondActivity will be added to task stack. stackBuilder.addParentStack(SecondActivity.class); // Add a SecondActivity intent to the task stack. stackBuilder.addNextIntent(resultIntent); // Obtain a PendingIntent for launching the task constructed by this builder. PendingIntent pendingIntent = stackBuilder.getPendingIntent(REQUEST_CODE, PendingIntent.FLAG_UPDATE_CURRENT); NotificationManager manager = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification.Builder(this) .setContentTitle("My Notification") .setContentText("Notification content") .setSmallIcon(android.R.drawable.ic_menu_view) .setContentIntent(pendingIntent) .build(); manager.notify(NOTIFICATION_ID, notification);
NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationCompat.Builder ncomp = new NotificationCompat.Builder(MainActivity.this); ncomp.setContentTitle("My Notification"); if (count == 0) ncomp.setContentText("Notification"); else ncomp.setContentText(count + " Notifications"); Intent resultIntent = new Intent(MainActivity.this, Message.class); resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainActivity.this); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); ncomp.setContentIntent(resultPendingIntent); ncomp.setTicker("Notification Listener"); ncomp.setSmallIcon(R.drawable.ic_launcher); ncomp.setAutoCancel(true); nManager.notify(NOTIFY_ID, ncomp.build()); count++;
// check PendingIntent for Activity boolean pendingIntentExists = (PendingIntent.getActivity( this, REQUEST_CODE, notifyIntent, PendingIntent.FLAG_NO_CREATE) != null); // check PendingIntent for backstack TaskStackBuilder stackBuilder = TaskStackBuilder.create( this ); stackBuilder.addParentStack( MainActivity.class ); stackBuilder.addNextIntent( notifyIntent ); boolean pendingIntentExists = (stackBuilder.getPendingIntent( REQUEST_CODE, PendingIntent.FLAG_NO_CREATE ) != null);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext); stackBuilder.addParentStack(returnTo); stackBuilder.addNextIntent(intent);