Java Code Examples for android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT

The following are Jave code examples for showing how to use FLAG_ACTIVITY_NEW_DOCUMENT of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: chromium-net-for-android   File: ApiCompatibilityUtils.java   View Source Code Vote up 6 votes
@SuppressWarnings("deprecation")
public static int getActivityNewDocumentFlag() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
    } else {
        return Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
    }
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: ChromeLauncherActivity.java   View Source Code Vote up 6 votes
/**
 * Creates an Intent that can be used to launch a {@link CustomTabActivity}.
 */
public static Intent createCustomTabActivityIntent(
        Context context, Intent intent, boolean addHerbExtras) {
    // Use the copy constructor to carry over the myriad of extras.
    Uri uri = Uri.parse(IntentHandler.getUrlFromIntent(intent));

    Intent newIntent = new Intent(intent);
    newIntent.setAction(Intent.ACTION_VIEW);
    newIntent.setClassName(context, CustomTabActivity.class.getName());
    newIntent.setData(uri);

    // If a CCT intent triggers First Run, then NEW_TASK will be automatically applied.  As
    // part of that, it will inherit the EXCLUDE_FROM_RECENTS bit from ChromeLauncherActivity,
    // so explicitly remove it to ensure the CCT does not get lost in recents.
    if ((newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
            || (newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
        newIntent.setFlags(
                newIntent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    }

    if (addHerbExtras) {
        // TODO(tedchoc|mariakhomenko): Specifically not marking the intent is from Chrome via
        //                              IntentHandler.addTrustedIntentExtras as it breaks the
        //                              redirect logic for triggering instant apps.  See if
        //                              this is better addressed in TabRedirectHandler long
        //                              term.
        newIntent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
    } else {
        IntentUtils.safeRemoveExtra(
                intent, CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME);
    }
    if (addHerbExtras) updateHerbIntent(context, newIntent);

    return newIntent;
}
 
Example 3
Project: chromium-for-android-56-debug-video   File: ChromeLauncherActivity.java   View Source Code Vote up 6 votes
/**
 * Records metrics gleaned from the Intent.
 */
private void recordIntentMetrics() {
    Intent intent = getIntent();
    IntentHandler.ExternalAppId source =
            IntentHandler.determineExternalIntentSource(getPackageName(), intent);
    if (intent.getPackage() == null && source != IntentHandler.ExternalAppId.CHROME) {
        int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        int maskedFlags = intent.getFlags() & flagsOfInterest;
        sIntentFlagsHistogram.record(maskedFlags);
    }
    MediaNotificationUma.recordClickSource(intent);
}
 
Example 4
Project: iosched-reader   File: SessionDetailModel.java   View Source Code Vote up 6 votes
private int getFlagForUrlLink() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
    } else {
        return Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
    }
}