List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:Main.java
public static void startActivity(Context mContext, Class className) { Intent intent = new Intent(); intent.setClass(mContext, className); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent);//from ww w. j a v a 2s . c o m }
From source file:Main.java
public static Intent getInstallIntent(Uri uri) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(uri, "application/vnd.android.package-archive"); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return i;//from ww w. j a va2 s. c om }
From source file:Main.java
public static void startActivity(Context mContext, String packageName, String className) { try {/*from w w w . j a v a2 s . co m*/ ComponentName com = new ComponentName(packageName, className); Intent intent = new Intent(); intent.setComponent(com); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
private static void startActivityByResolve(Context context, ResolveInfo r, Intent intent) { Intent intent2 = new Intent(intent); intent2.setClassName(r.activityInfo.packageName, r.activityInfo.name); intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.getApplicationContext().startActivity(intent2); }
From source file:Main.java
/** * Restart application (just relauch the first page of package) * * * @param context Context/*from w w w. j a v a 2 s. c o m*/ */ public static void restartApplication(Context context) { final Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(intent); }
From source file:Main.java
public static Intent getPdfFileIntent(String param) { 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, "application/pdf"); return intent; }
From source file:Main.java
public static Intent getWordFileIntent(String param) { 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, "application/msword"); return intent; }
From source file:Main.java
public static Intent getImageFileIntent(File file) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), "image/*"); return intent; }
From source file:Main.java
public static Intent getAllFileIntent(String param) { 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, "*/*"); return intent; }
From source file:Main.java
public static Intent getOpenFileIntent(File file) { if (file == null || !file.exists() || !file.isFile()) { return null; }//from w w w . ja v a 2s . com String extension = MimeTypeMap.getFileExtensionFromUrl(file.getAbsolutePath()); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (extension == null || mimeType == null) { return null; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), mimeType); return intent; }