get New Document Intent Flag - Android Intent

Android examples for Intent:Intent Bundle

Description

get New Document Intent Flag

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;

public class Main {
    /**/* w  ww.ja va 2s.c  om*/
     * @return {@link Intent#FLAG_ACTIVITY_NEW_DOCUMENT} on API 21 and above and {@link Intent#FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET} on other versions
     */
    @TargetApi(21)
    public static int getNewDocumentIntentFlag() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            return Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        } else {
            //noinspection deprecation
            return Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
        }
    }
}

Related Tutorials