Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

In this page you can find the example usage for android.content Intent addFlags.

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:Main.java

public static Intent getAppNotificationOpenManagerIntent() {
    Intent intent = new Intent();
    intent.setClassName("com.lenovo.systemuiplus",
            "com.lenovo.systemuiplus.notifymanager.AppNotificationOpenManager");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:Main.java

public static void shareText(Context context, String title, String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);// Intent.createChooser(intent, title)
}

From source file:Main.java

public static boolean startActivityUsingScheme(Activity a, String scheme, Bundle args) {
    Uri uri = Uri.parse(scheme + "://");
    Intent intent = new Intent(Intent.ACTION_RUN, uri);
    boolean result = true;
    try {//from ww w . j  a  v a2  s.c o m
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (args != null)
            intent.putExtras(args);
        a.startActivity(intent);
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:Main.java

public static boolean startActivity(Activity a, String packageName, Bundle args, int flags) {
    PackageManager pm = a.getPackageManager();
    boolean result = true;
    try {//from w  w w  .j  av a 2s. c o  m
        Intent intent = pm.getLaunchIntentForPackage(packageName);
        if (null != intent) {
            intent.addFlags(flags);
            if (args != null)
                intent.putExtras(args);
            a.startActivity(intent);
        }
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:Main.java

public static boolean startActivity(Context a, String packageName) {
    PackageManager pm = a.getPackageManager();
    boolean result = true;
    try {/*from ww w.  ja  v a  2s  .c o  m*/
        Intent intent = pm.getLaunchIntentForPackage(packageName);
        if (intent != null) {
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            //         intent.addCategory(Intent.CATEGORY_LAUNCHER);
            a.startActivity(intent);
        } else {
            result = startActivityUsingScheme(a, packageName);
        }
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = startActivityUsingScheme(a, packageName);
    }
    return result;
}

From source file:Main.java

public static boolean startActivity(Activity a, String packageName, Bundle args) {
    PackageManager pm = a.getPackageManager();
    boolean result = true;
    try {//w w w . j a v a 2  s.  c o m
        Intent intent = pm.getLaunchIntentForPackage(packageName);
        if (null != intent) {
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            if (args != null)
                intent.putExtras(args);
            a.startActivity(intent);
        } else {
            result = startActivityUsingScheme(a, packageName, args);
        }
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = startActivityUsingScheme(a, packageName, args);
    }
    return result;
}

From source file:Main.java

public static void exitGapdeApp_auto(Context context) {
    Intent intent = new Intent("android.intent.action.VIEW",
            android.net.Uri.parse("androidauto://appExit?sourceApplication=launcher"));
    intent.setPackage("com.autonavi.amapauto");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from w ww  . j  av  a  2 s .  c o m
}

From source file:Main.java

public static void sendSchemeForResultAddMediaStack(Activity context, String mediaActivityUrl, String url,
        int requestCode, Bundle bundle) {
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);
    context.startActivity(intent);//from w ww  .j  av  a 2 s  .  c  om
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void sendSchemeAddMediaStack(Context context, String mediaActivityUrl, String url,
        Bundle bundle) {//from   w w w .  j  a  v  a2  s  .c o  m
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);
    context.startActivity(intent);
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivity(intent);
}

From source file:Main.java

@SuppressLint("NewApi")
public static void sendSchemeAddMediaStack(Fragment context, String mediaActivityUrl, String url,
        Bundle bundle) {//from w  w w.ja  v  a  2 s  .  c om
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);
    context.startActivity(intent);
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivity(intent);
}