Search in sources :

Example 6 with TaskStackBuilder

use of androidx.core.app.TaskStackBuilder in project orgzly-android by orgzly.

the class ShareActivity method createNewNoteIntent.

public static PendingIntent createNewNoteIntent(Context context, SavedSearch savedSearch) {
    Intent resultIntent = createNewNoteInNotebookIntent(context, null);
    if (savedSearch != null && savedSearch.getQuery() != null) {
        resultIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, savedSearch.getQuery());
    }
    // 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(context);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(ShareActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    // return PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) AppIntent(com.orgzly.android.AppIntent) TaskStackBuilder(androidx.core.app.TaskStackBuilder)

Example 7 with TaskStackBuilder

use of androidx.core.app.TaskStackBuilder in project EhViewer by seven332.

the class AppCompatPreferenceActivity method onSupportNavigateUp.

/**
 * This method is called whenever the user chooses to navigate Up within your application's
 * activity hierarchy from the action bar.
 *
 * <p>If a parent was specified in the manifest for this activity or an activity-alias to it,
 * default Up navigation will be handled automatically. See
 * {@link #getSupportParentActivityIntent()} for how to specify the parent. If any activity
 * along the parent chain requires extra Intent arguments, the Activity subclass
 * should override the method {@link #onPrepareSupportNavigateUpTaskStack(androidx.core.app.TaskStackBuilder)}
 * to supply those arguments.</p>
 *
 * <p>See <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and
 * Back Stack</a> from the developer guide and
 * <a href="{@docRoot}design/patterns/navigation.html">Navigation</a> from the design guide
 * for more information about navigating within your app.</p>
 *
 * <p>See the {@link androidx.core.app.TaskStackBuilder} class and the Activity methods
 * {@link #getSupportParentActivityIntent()}, {@link #supportShouldUpRecreateTask(android.content.Intent)}, and
 * {@link #supportNavigateUpTo(android.content.Intent)} for help implementing custom Up navigation.</p>
 *
 * @return true if Up navigation completed successfully and this Activity was finished,
 *         false otherwise.
 */
public boolean onSupportNavigateUp() {
    Intent upIntent = getSupportParentActivityIntent();
    if (upIntent != null) {
        if (supportShouldUpRecreateTask(upIntent)) {
            TaskStackBuilder b = TaskStackBuilder.create(this);
            onCreateSupportNavigateUpTaskStack(b);
            onPrepareSupportNavigateUpTaskStack(b);
            b.startActivities();
            try {
                ActivityCompat.finishAffinity(this);
            } catch (IllegalStateException e) {
                // This can only happen on 4.1+, when we don't have a parent or a result set.
                // In that case we should just finish().
                finish();
            }
        } else {
            // This activity is part of the application's task, so simply
            // navigate up to the hierarchical parent activity.
            supportNavigateUpTo(upIntent);
        }
        return true;
    }
    return false;
}
Also used : Intent(android.content.Intent) TaskStackBuilder(androidx.core.app.TaskStackBuilder)

Example 8 with TaskStackBuilder

use of androidx.core.app.TaskStackBuilder in project DeepLinkDispatch by airbnb.

the class MainActivity method getTaskStackBuilder.

@NotNull
private static TaskStackBuilder getTaskStackBuilder(Context context, String action) {
    Intent detailsIntent = new Intent(context, SecondActivity.class).setAction(action);
    Intent parentIntent = new Intent(context, MainActivity.class).setAction(action);
    TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
    taskStackBuilder.addNextIntent(parentIntent);
    taskStackBuilder.addNextIntent(detailsIntent);
    return taskStackBuilder;
}
Also used : Intent(android.content.Intent) TaskStackBuilder(androidx.core.app.TaskStackBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with TaskStackBuilder

use of androidx.core.app.TaskStackBuilder in project DeepLinkDispatch by airbnb.

the class MainActivity method intentForTaskStackBuilderMethods.

/**
 * Handles deep link with params.
 * @param context of the activity
 * @param bundle expected to contain the key {@code qp}.
 * @return TaskStackBuilder set with first intent to start {@link MainActivity} and second intent
 * to start {@link SecondActivity}.
 */
@DeepLink("http://example.com/deepLink/{id}/{name}/{place}")
public static TaskStackBuilder intentForTaskStackBuilderMethods(Context context, Bundle bundle) {
    Log.d(TAG, "without query parameter :");
    if (bundle != null && bundle.containsKey("qp")) {
        Log.d(TAG, "found new parameter :with query parameter :" + bundle.getString("qp"));
    }
    TaskStackBuilder taskStackBuilder = getTaskStackBuilder(context, ACTION_DEEP_LINK_COMPLEX);
    return taskStackBuilder;
}
Also used : TaskStackBuilder(androidx.core.app.TaskStackBuilder) DeepLink(com.airbnb.deeplinkdispatch.DeepLink)

Example 10 with TaskStackBuilder

use of androidx.core.app.TaskStackBuilder in project android-oss by kickstarter.

the class PushNotifications method surveyResponseContentIntent.

@NonNull
private PendingIntent surveyResponseContentIntent(@NonNull final PushNotificationEnvelope envelope, @NonNull final SurveyResponse surveyResponse) {
    final Intent activityFeedIntent = new Intent(this.context, ActivityFeedActivity.class);
    final Intent surveyResponseIntent = new Intent(this.context, SurveyResponseActivity.class).putExtra(IntentKey.SURVEY_RESPONSE, surveyResponse);
    final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this.context).addNextIntentWithParentStack(activityFeedIntent).addNextIntent(surveyResponseIntent);
    return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_IMMUTABLE);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(androidx.core.app.TaskStackBuilder) SurveyResponseActivity(com.kickstarter.ui.activities.SurveyResponseActivity) NonNull(androidx.annotation.NonNull)

Aggregations

TaskStackBuilder (androidx.core.app.TaskStackBuilder)16 Intent (android.content.Intent)12 PendingIntent (android.app.PendingIntent)10 NonNull (androidx.annotation.NonNull)4 Notification (android.app.Notification)3 NotificationCompat (androidx.core.app.NotificationCompat)3 Settings (com.android.settings.Settings)3 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 Bundle (android.os.Bundle)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 DeepLink (com.airbnb.deeplinkdispatch.DeepLink)1 MediaMetadata (com.google.android.gms.cast.MediaMetadata)1 MessagesActivity (com.kickstarter.ui.activities.MessagesActivity)1 SurveyResponseActivity (com.kickstarter.ui.activities.SurveyResponseActivity)1 UpdateActivity (com.kickstarter.ui.activities.UpdateActivity)1 AppIntent (com.orgzly.android.AppIntent)1 NotNull (org.jetbrains.annotations.NotNull)1