Example usage for android.content Intent FLAG_ACTIVITY_NEW_TASK

List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK

Introduction

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

Prototype

int FLAG_ACTIVITY_NEW_TASK

To view the source code for android.content Intent FLAG_ACTIVITY_NEW_TASK.

Click Source Link

Document

If set, this activity will become the start of a new task on this history stack.

Usage

From source file:Main.java

public static Intent getShowOrbotStartIntent() {
    Intent intent = new Intent(ACTION_START_TOR);
    intent.setPackage(ORBOT_PACKAGE_NAME);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:Main.java

public static void launchAppMarket(Context context, String pkgname) {
    Uri uri = Uri.parse("market://details?id=" + pkgname);
    // uri = Uri.parse("market://details?id=" + "com.tencent.mobileqq");
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from w w  w .  ja  v  a 2  s .c o  m
}

From source file:Main.java

public static void installApk(Context context, String apkUrl) {
    File file = new File(apkUrl);
    if (!file.exists())
        return;/*from   w w w  .  jav a2 s.com*/
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse(apkUrl), type);
    context.startActivity(intent);
}

From source file:Main.java

public static void install(Context context, String fileName) {
    if (TextUtils.isEmpty(fileName) || context == null) {
        return;/* w ww .j  av  a2 s. c o m*/
    }
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

private static Intent getIntentByType(String param, String type) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, type);/*from  w w  w.  j a v a  2  s .  co m*/
    return intent;
}

From source file:Main.java

public static void installApk(Context context, File file) {
    if (context != null && isFileExists(file)) {
        Uri uri = Uri.fromFile(new File(file.getAbsolutePath()));
        Intent installIntent = new Intent();
        installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        installIntent.setAction(Intent.ACTION_VIEW);
        String type = "application/vnd.android.package-archive";
        installIntent.putExtra("loadapk", "loadapk");
        installIntent.setDataAndType(uri, type);
        context.startActivity(installIntent);
    }//w  w  w .jav  a  2  s.  co m
}

From source file:Main.java

public static void applyPermission(Context context) {
    Intent intent = new Intent();
    intent.setClassName("com.android.settings", "com.android.settings.Settings$OverlaySettingsActivity");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (isIntentAvailable(intent, context)) {
        context.startActivity(intent);/*from w w w. j av  a  2  s.c  o m*/
    } else {
        intent.setClassName("com.qihoo360.mobilesafe", "com.qihoo360.mobilesafe.ui.index.AppEnterActivity");
        if (isIntentAvailable(intent, context)) {
            context.startActivity(intent);
        } else {
            Log.e(TAG, "can't open permission page with particular name, please use "
                    + "\"adb shell dumpsys activity\" command and tell me the name of the float window permission page");
        }
    }
}

From source file:Main.java

/**
 * @param artistName// w w w. j av a 2s  . c  om
 */
public static void shopFor(Context mContext, String artistName) {
    String str = "https://market.android.com/search?q=%s&c=music&featured=MUSIC_STORE_SEARCH";
    Intent shopIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(str, Uri.encode(artistName))));
    shopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shopIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    mContext.startActivity(shopIntent);
}

From source file:Main.java

private static Intent getComponentIntent(String packageName, String className, Bundle bundle) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (bundle != null)
        intent.putExtras(bundle);//from  ww  w. j ava 2s .c  om
    ComponentName cn = new ComponentName(packageName, className);
    intent.setComponent(cn);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static boolean install(Context context, File file) {
    if (file == null || !file.exists() || !file.isFile()) {
        return false;
    }//from www  .j a  v a  2 s. c o m
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    return true;
}