android.support.v4.app.TaskStackBuilder#startActivities ( )源码实例Demo

下面列出了android.support.v4.app.TaskStackBuilder#startActivities ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void processDeepLink(Intent intent) {
    if (intent == null || intent.getData() == null) {
        return;
    }

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    List<String> segments = intent.getData().getPathSegments();
    if (segments.isEmpty()) {
        Intent launcherIntent = getPackageManager().getLaunchIntentForPackage(getPackageName());
        if (launcherIntent != null) {
            startActivity(launcherIntent.putExtras(intent));
        }
        return;
    }

    for (String segment : intent.getData().getPathSegments()) {
        if (activityMap.containsKey(segment)) {
            Intent nextIntent = new Intent(this, activityMap.get(segment)).putExtras(intent);
            stackBuilder.addNextIntent(nextIntent);
        }
    }
    stackBuilder.startActivities();
}
 
源代码2 项目: android_9.0.0_r45   文件: NavController.java
/**
 * Attempts to navigate up in the navigation hierarchy. Suitable for when the
 * user presses the "Up" button marked with a left (or start)-facing arrow in the upper left
 * (or starting) corner of the app UI.
 *
 * <p>The intended behavior of Up differs from {@link #popBackStack() Back} when the user
 * did not reach the current destination from the application's own task. e.g. if the user
 * is viewing a document or link in the current app in an activity hosted on another app's
 * task where the user clicked the link. In this case the current activity (determined by the
 * context used to create this NavController) will be {@link Activity#finish() finished} and
 * the user will be taken to an appropriate destination in this app on its own task.</p>
 *
 * @return true if navigation was successful, false otherwise
 */
public boolean navigateUp() {
    if (mBackStack.size() == 1) {
        // If there's only one entry, then we've deep linked into a specific destination
        // on another task so we need to find the parent and start our task from there
        NavDestination currentDestination = getCurrentDestination();
        int destId = currentDestination.getId();
        NavGraph parent = currentDestination.getParent();
        while (parent != null) {
            if (parent.getStartDestination() != destId) {
                TaskStackBuilder parentIntents = new NavDeepLinkBuilder(NavController.this)
                        .setDestination(parent.getId())
                        .createTaskStackBuilder();
                parentIntents.startActivities();
                if (mActivity != null) {
                    mActivity.finish();
                }
                return true;
            }
            destId = parent.getId();
            parent = parent.getParent();
        }
        // We're already at the startDestination of the graph so there's no 'Up' to go to
        return false;
    } else {
        return popBackStack();
    }
}
 
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码4 项目: your-local-weather   文件: BaseActivity.java
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码5 项目: privacy-friendly-dame   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码6 项目: privacy-friendly-ludo   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码7 项目: privacy-friendly-pedometer   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码8 项目: privacy-friendly-weather   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码10 项目: RetailStore   文件: BaseActivity.java
/**
 * This utility method handles Up navigation intents by searching for a parent activity and
 * navigating there if defined. When using this for an activity make sure to define both the
 * native parentActivity as well as the AppCompat one when supporting API levels less than 16.
 * when the activity has a single parent activity. If the activity doesn't have a single parent
 * activity then don't define one and this method will use back button functionality. If "Up"
 * functionality is still desired for activities without parents then use
 * {@code syntheticParentActivity} to define one dynamically.
 * <p>
 * Note: Up navigation intents are represented by a back arrow in the top left of the Toolbar
 * in Material Design guidelines.
 *
 * @param currentActivity         Activity in use when navigate Up action occurred.
 * @param syntheticParentActivity Parent activity to use when one is not already configured.
 */
public static void navigateUpOrBack(Activity currentActivity,
                                    Class<? extends Activity> syntheticParentActivity) {
    // Retrieve parent activity from AndroidManifest.
    Intent intent = NavUtils.getParentActivityIntent(currentActivity);

    // Synthesize the parent activity when a natural one doesn't exist.
    if (intent == null && syntheticParentActivity != null) {
        try {
            intent = NavUtils.getParentActivityIntent(currentActivity, syntheticParentActivity);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    if (intent == null) {
        // No parent defined in manifest. This indicates the activity may be used by
        // in multiple flows throughout the app and doesn't have a strict parent. In
        // this case the navigation up button should act in the same manner as the
        // back button. This will result in users being forwarded back to other
        // applications if currentActivity was invoked from another application.
        currentActivity.onBackPressed();
    } else {
        if (NavUtils.shouldUpRecreateTask(currentActivity, intent)) {
            // Need to synthesize a backstack since currentActivity was probably invoked by a
            // different app. The preserves the "Up" functionality within the app according to
            // the activity hierarchy defined in AndroidManifest.xml via parentActivity
            // attributes.
            TaskStackBuilder builder = TaskStackBuilder.create(currentActivity);
            builder.addNextIntentWithParentStack(intent);
            builder.startActivities();
        } else {
            // Navigate normally to the manifest defined "Up" activity.
            NavUtils.navigateUpTo(currentActivity, intent);
        }
    }
}
 
/**
 * 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
 */
private void createBackStack(Intent intent)
{
    if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN )
    {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    }
    else
    {
        startActivity(intent);
        finish();
    }
}
 
源代码12 项目: good-weather   文件: BaseActivity.java
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码13 项目: privacy-friendly-qr-scanner   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
源代码15 项目: privacy-friendly-torchlight   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(this);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        startActivity(intent);
        finish();
    }
}
 
private void doCoreTappedActions(Message chatMessage) {
    TaskStackBuilder stackBuilder = stackBuilderForNotificationTap(chatMessage);
    if (stackBuilder.getIntentCount() != 0) {
        stackBuilder.startActivities();
    }
}
 
源代码17 项目: privacy-friendly-netmonitor   文件: BaseActivity.java
/**
 * 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
 */
private void createBackStack(Intent intent) {
    TaskStackBuilder builder = TaskStackBuilder.create(this);
    builder.addNextIntentWithParentStack(intent);
    builder.startActivities();
}