use of android.support.v4.app.TaskStackBuilder in project iosched by google.
the class ActivityUtils method createBackStack.
/**
* Enables back navigation for activities that are launched from the NavBar. See {@code
* AndroidManifest.xml} to find out the parent activity names for each activity.
*
* @param intent
*/
public static void createBackStack(Activity activity, Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
TaskStackBuilder builder = TaskStackBuilder.create(activity);
builder.addNextIntentWithParentStack(intent);
builder.startActivities();
} else {
activity.startActivity(intent);
activity.finish();
}
}
use of android.support.v4.app.TaskStackBuilder in project physical-web by google.
the class Utils method createBroadcastNotification.
/**
* Surface a notification to the user that the Physical Web is broadcasting. The notification
* specifies the transport or URL that is being broadcast and cannot be swiped away.
* @param context
* @param stopServiceReceiver
* @param broadcastNotificationId
* @param title
* @param text
* @param filter
*/
public static void createBroadcastNotification(Context context, BroadcastReceiver stopServiceReceiver, int broadcastNotificationId, CharSequence title, CharSequence text, String filter) {
Intent resultIntent = new Intent();
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
context.registerReceiver(stopServiceReceiver, new IntentFilter(filter));
PendingIntent pIntent = PendingIntent.getBroadcast(context, 0, new Intent(filter), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_leak_add_white_24dp).setContentTitle(title).setContentText(text).setOngoing(true).addAction(android.R.drawable.ic_menu_close_clear_cancel, context.getString(R.string.stop), pIntent);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(broadcastNotificationId, builder.build());
}
use of android.support.v4.app.TaskStackBuilder in project Klyph by jonathangerbaud.
the class KlyphNotification method sendNotification.
public static void sendNotification(Context context, Builder builder) {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
Intent resultIntent = new Intent(context, MainActivity.class);
resultIntent.putExtra(KlyphBundleExtras.SHOW_NOTIFICATION_MENU, true);
stackBuilder.addNextIntentWithParentStack(resultIntent);
int intentCode = (int) Math.round(Math.random() * 1000000);
// Gets a PendingIntent containing the entire back stack
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(intentCode, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
Intent intent = new Intent(context, NotificationGroupDeletedReceiver.class);
builder.setDeleteIntent(PendingIntent.getBroadcast(context.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final String tag = context.getPackageName() + "_grouped";
final int id = 0;
// pair (tag, id) must be unique
// tag is the unique key
mNotificationManager.notify(tag, id, builder.build());
}
use of android.support.v4.app.TaskStackBuilder in project k-9 by k9mail.
the class NotificationActionCreator method buildMessageListBackStack.
private TaskStackBuilder buildMessageListBackStack(Account account, String folderName) {
TaskStackBuilder stack = skipFolderListInBackStack(account, folderName) ? buildAccountsBackStack() : buildFolderListBackStack(account);
LocalSearch search = new LocalSearch(folderName);
search.addAllowedFolder(folderName);
search.addAccountUuid(account.getUuid());
Intent intent = MessageList.intentDisplaySearch(context, search, false, true, true);
stack.addNextIntent(intent);
return stack;
}
use of android.support.v4.app.TaskStackBuilder in project android-oss by kickstarter.
the class PushNotifications method projectUpdateContentIntent.
@NonNull
private PendingIntent projectUpdateContentIntent(@NonNull final PushNotificationEnvelope envelope, @NonNull final Update update, @NonNull final String projectParam) {
final Intent projectIntent = new Intent(context, ProjectActivity.class).putExtra(IntentKey.PROJECT_PARAM, projectParam);
final Intent updateIntent = new Intent(context, WebViewActivity.class).putExtra(IntentKey.URL, update.urls().web().update()).putExtra(IntentKey.PUSH_NOTIFICATION_ENVELOPE, envelope);
final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context).addNextIntentWithParentStack(projectIntent).addNextIntent(updateIntent);
return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
}
Aggregations