List of usage examples for android.content Intent setDataAndType
public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type)
From source file:Main.java
public static void callImage(Context context, String path) { Intent intent = new Intent(); intent.setDataAndType(Uri.fromFile(new File(path)), "image/*"); context.startActivity(intent);/*from w w w . j ava2 s. c om*/ }
From source file:Main.java
public static void callText(Context context, String path) { Intent intent = new Intent(); intent.setDataAndType(Uri.fromFile(new File(path)), "text/plain"); context.startActivity(intent);//from w w w .j a v a 2s .c om }
From source file:Main.java
public static void installApkFileFromUri(Context context, Uri appPath) { Intent intent = new Intent(); intent.setDataAndType(appPath, "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);// ww w . jav a 2 s. c o m }
From source file:Main.java
public static boolean resolves(PackageManager packageManager, String action, Uri uri, String mimeType) { Intent intent = new Intent(action); intent.setDataAndType(uri, mimeType); return intent.resolveActivity(packageManager) != null; }
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;// w w w .ja v a 2 s .c om }
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);/* w w w . j a v a 2 s. co m*/ }
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 w w w . j a v a2 s.c o m*/ }
From source file:Main.java
public static Intent getInstallIntent(Uri uri) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.android.package-archive"); return intent; }
From source file:Main.java
public static void installApk(Context context, String apkFilePath) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + apkFilePath), "application/vnd.android.package-archive"); context.startActivity(intent);/*ww w . j a v a 2 s.c om*/ }
From source file:Main.java
public static void installApk(Context context, String filename) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(filename)), "application/vnd.android.package-archive"); context.startActivity(intent);/*from w ww . jav a2s . c om*/ }