use of android.app.TaskStackBuilder in project Parse-SDK-Android by ParsePlatform.
the class TaskStackBuilderHelper method startActivities.
public static void startActivities(Context context, Class<? extends Activity> cls, Intent activityIntent) {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(cls);
stackBuilder.addNextIntent(activityIntent);
stackBuilder.startActivities();
}
use of android.app.TaskStackBuilder in project Fairphone by Kwamecorp.
the class PeaceOfMindBroadCastReceiver method setPeaceOfMindIconInNotificationBar.
/**
* Sets the Peace of mind icon on the notification bar
* @param putIcon if true the icon is put otherwise it is removed
* @param wasInterrupted when true, an extra notification is sent to inform the user that Peace of mind was ended
*/
private void setPeaceOfMindIconInNotificationBar(boolean putIcon, boolean wasInterrupted) {
NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (putIcon) {
//just in case the user didn't clear it
manager.cancel(PEACE_OF_MIND_INTERRUPTED_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.peace_system_bar_icon).setContentTitle(mContext.getResources().getString(R.string.app_name)).setContentText(mContext.getResources().getString(R.string.peace_on_notification));
Intent resultIntent = new Intent(mContext, PeaceOfMindActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(PeaceOfMindActivity.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);
builder.setContentIntent(resultPendingIntent);
Notification notificationWhileRunnig = builder.build();
notificationWhileRunnig.flags |= Notification.FLAG_NO_CLEAR;
// Add notification
manager.notify(PEACE_OF_MIND_ON_NOTIFICATION, notificationWhileRunnig);
} else {
manager.cancel(PEACE_OF_MIND_ON_NOTIFICATION);
//send a notification saying that the peace was ended
if (wasInterrupted) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.peace_system_bar_icon).setAutoCancel(true).setContentTitle(mContext.getResources().getString(R.string.app_name)).setContentText(mContext.getResources().getString(R.string.peace_off_notification)).setTicker(mContext.getResources().getString(R.string.peace_off_notification));
manager.notify(PEACE_OF_MIND_INTERRUPTED_NOTIFICATION, builder.build());
}
}
}
use of android.app.TaskStackBuilder in project android_frameworks_base by AOSPA.
the class MainActivity method sendNotification.
private void sendNotification(int count) {
Notification.Builder builder = new Notification.Builder(this).setContentTitle(String.format("%s OSU available", count)).setContentText("Choose one to connect").setSmallIcon(android.R.drawable.ic_dialog_info).setAutoCancel(false);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
use of android.app.TaskStackBuilder in project android_frameworks_base by crdroidandroid.
the class MainActivity method sendNotification.
private void sendNotification(int count) {
Notification.Builder builder = new Notification.Builder(this).setContentTitle(String.format("%s OSU available", count)).setContentText("Choose one to connect").setSmallIcon(android.R.drawable.ic_dialog_info).setAutoCancel(false);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Aggregations