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

/**
 * install an apk bu apkPath/* www  . j  a  va 2 s . c o m*/
 *
 * @param context Context
 * @param apkPath apkPath
 */
public static final void installApk(Context context, String apkPath) {
    if (TextUtils.isEmpty(apkPath)) {
        return;
    }
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(new File(apkPath)), "application/vnd.android.package-archive");
    context.startActivity(intent);
}

From source file:Main.java

private static Intent getVideoFileIntent(String filePath) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(new File(filePath));
    intent.setDataAndType(uri, "video/*");
    return intent;
}

From source file:Main.java

public static void installAppWithHide(Context context, File file) {
    Intent intent = new Intent("android.intent.action.VIEW.HIDE");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);//from   w w  w  .j a v a 2 s  .c  o  m
}

From source file:Main.java

public static void launchActivityForResult(Activity context, Class<?> activity, int requestCode) {
    Intent intent = new Intent(context, activity);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    context.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static Intent getAudioFileIntent(String param) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("oneshot", 0);
    intent.putExtra("configchange", 0);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "audio/*");
    return intent;
}

From source file:Main.java

public static void jumpToActivity(Context context, ComponentName componentName) {
    Intent mIntent = new Intent();
    mIntent.addFlags(268435456);
    mIntent.setComponent(componentName);
    mIntent.setAction("android.intent.action.VIEW");
    context.startActivity(mIntent);/*from   w  ww.  j  a  v  a2s  . c o  m*/
}

From source file:Main.java

private static Intent getNormalCameraIntent() {
    Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    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  .  j  a v  a 2s .  co  m*/
}

From source file:Main.java

public static void startActivity(Context context, Class<?> c, boolean clearStack) {
    Intent intent = new Intent(context, c);
    if (clearStack)
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);/*from  w w  w.ja  va2s. co  m*/
}

From source file:Main.java

public static void newClearTask(Activity activity, Class<?> homeActivityClass) {
    activity.finish();//from   w w w  . j ava  2 s  .co m
    Intent intent = new Intent(activity, homeActivityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);
}