Search in sources :

Example 26 with TaskStackBuilder

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();
    }
}
Also used : TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

Example 27 with TaskStackBuilder

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());
}
Also used : IntentFilter(android.content.IntentFilter) NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

Example 28 with TaskStackBuilder

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());
}
Also used : NotificationManager(android.app.NotificationManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

Example 29 with TaskStackBuilder

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;
}
Also used : LocalSearch(com.fsck.k9.search.LocalSearch) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder)

Example 30 with TaskStackBuilder

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);
}
Also used : ProjectActivity(com.kickstarter.ui.activities.ProjectActivity) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) NonNull(android.support.annotation.NonNull)

Aggregations

Intent (android.content.Intent)39 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)38 PendingIntent (android.app.PendingIntent)34 NotificationCompat (android.support.v4.app.NotificationCompat)20 NotificationManager (android.app.NotificationManager)14 Bitmap (android.graphics.Bitmap)13 InputStream (java.io.InputStream)10 IOException (java.io.IOException)8 URL (java.net.URL)8 Notification (android.app.Notification)7 Context (android.content.Context)5 Uri (android.net.Uri)5 SharedPreferences (android.content.SharedPreferences)3 Resources (android.content.res.Resources)3 Cursor (android.database.Cursor)3 RemoteViews (android.widget.RemoteViews)3 TaskStackBuilder (android.app.TaskStackBuilder)2 ContentResolver (android.content.ContentResolver)2 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2