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 void showInputMethodSettingsPage(Context context) {
    Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from w  w  w.  j a v  a 2  s.c om*/
}

From source file:Main.java

public static Intent getHSM_PROTECTED_APPSIntent() {
    Intent intent = new Intent("huawei.intent.action.HSM_PROTECTED_APPS");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:Main.java

public static void startXiaomiApp(Context context) {
    Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.xiaomi.smarthome");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/* ww  w . ja  v  a  2 s .  co m*/
}

From source file:Main.java

public static boolean uninstallApk(Context context, String packageName) {
    if (TextUtils.isEmpty(packageName)) {
        return false;
    }//w  ww .j a v a 2s . co  m
    Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + packageName));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}

From source file:Main.java

private static void addPhotoPickerExtras(Intent intent, Uri photoUri) {
    intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, photoUri));
}

From source file:Main.java

private static void showAppInMarket(Context context, String desiredPackageName) {
    String url = "";

    try {//from  w ww . ja  v a 2 s . c o m
        //Check whether Google Play store is installed or not:
        context.getPackageManager().getPackageInfo("com.android.vending", 0);
        url = "market://details?id=" + desiredPackageName;
    } catch (final Exception e) {
        url = "https://play.google.com/store/apps/details?id=" + desiredPackageName;
    }

    //Open the app page in Google Play store:
    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void restartClearActivity(Activity activity) {
    if (activity == null)
        return;/*from  w  w w  .  j av  a  2  s  .c  o  m*/
    Context ctx = activity.getApplicationContext();
    Intent intent;
    intent = activity.getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    activity.finish();
    activity.overridePendingTransition(0, 0);

    ctx.startActivity(intent);
    activity.overridePendingTransition(0, 0);

}

From source file:Main.java

public static void goHome(Activity currentActivity, Class<?> homeActivityClass) {
    Intent parentActivityIntent = new Intent(currentActivity, homeActivityClass);
    parentActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    currentActivity.startActivity(parentActivityIntent);
    currentActivity.finish();/*from  w  w w  .j  a  v a2 s  . c  o m*/
}

From source file:Main.java

public static Intent getCallIntent(String phoneNumber) {
    Intent intent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNumber));
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static void restartClearActivityOutside(Activity activity) {
    if (activity == null)
        return;/*ww  w.ja v  a2s  .co  m*/
    Context ctx = activity.getApplicationContext();
    Intent intent;
    intent = activity.getIntent();
    intent.addFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    activity.finish();
    activity.overridePendingTransition(0, 0);

    ctx.startActivity(intent);
    activity.overridePendingTransition(0, 0);

}