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());
taskStackBuilder.addNextIntentWithParentStack(detailIntentForToday); PendingIntent resultPendingIntent = taskStackBuilder .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notificationManager.notify(WEATHER_NOTIFICATION_ID, notificationBuilder.build());
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());
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setAutoCancel(true) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Running") .setContentText("App is running") .setTicker("My app") .setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = mBuilder.build(); long[] vibrate = { 500,1000 }; notification.vibrate = vibrate; mNotificationManager.notify(appRunningNotificationID, 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);
// 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);
PendingIntent contentIntent ; Intent intent = new Intent(this,TestActivity.class); intent.putExtra("extra","Test"); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(ArticleDetailedActivity.class); contentIntent = 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());
taskStackBuilder.addNextIntentWithParentStack(detailIntentForToday); PendingIntent resultPendingIntent = taskStackBuilder .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notificationManager.notify(WEATHER_NOTIFICATION_ID, notificationBuilder.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 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);
PendingIntent contentIntent ; Intent intent = new Intent(this,TestActivity.class); intent.putExtra("extra","Test"); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(ArticleDetailedActivity.class); contentIntent = 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());
taskStackBuilder.addNextIntentWithParentStack(detailIntentForToday); PendingIntent resultPendingIntent = taskStackBuilder .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notificationManager.notify(WEATHER_NOTIFICATION_ID, notificationBuilder.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);
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);
taskStackBuilder.addNextIntentWithParentStack(detailIntentForToday); PendingIntent resultPendingIntent = taskStackBuilder .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notificationManager.notify(WEATHER_NOTIFICATION_ID, notificationBuilder.build());