List of usage examples for android.content Context startActivity
public abstract void startActivity(@RequiresPermission Intent intent);
From source file:Main.java
public static void goHome(Context context) { Intent mHomeIntent = new Intent(Intent.ACTION_MAIN); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); context.startActivity(mHomeIntent); }
From source file:Main.java
public static void startUnistalledApp(Context mContext, String pkgName) { Uri packageUri = Uri.parse("package:" + pkgName); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri); uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(uninstallIntent); }
From source file:Main.java
public static Boolean startApp(Context context, String appPackageName) { Intent intent = new Intent(); intent = context.getPackageManager().getLaunchIntentForPackage(appPackageName); if (intent == null) { return false; }/*from w ww . jav a2 s . c o m*/ context.startActivity(intent); return true; }
From source file:Main.java
public static void installApkByPath(Context context, String filePath) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); }
From source file:Main.java
public static void install(Context context, String filePath) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); }
From source file:Main.java
public static void forward(Context context, Class<?> dest, Bundle extras) { Intent intent = new Intent(context, dest); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (null != extras) { intent.putExtras(extras);// www .j a v a 2 s . co m } context.startActivity(intent); }
From source file:Main.java
public static void uninstallApk(Context ctx, String packageName) { Uri packageURI = Uri.parse("package:" + packageName); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(uninstallIntent); }
From source file:Main.java
/** * start home intent//from w w w. j a v a2s .c o m * * @param context */ public static void startHomeActivity(Context context) { Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); context.startActivity(homeIntent); }
From source file:Main.java
public static void installApp(Context context, File apkFile) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static void installApp(Context context, File file) { 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); }