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 boolean playAudio(Context context, String mrl, String name) { try {//from w w w . j av a 2s. c o m Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(mrl), "audio/*"); context.startActivity(intent); return true; } catch (android.content.ActivityNotFoundException ex) { } return false; }
From source file:Main.java
public static void installApk(Context context, File file) { Uri packageUri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW, packageUri); intent.setDataAndType(packageUri, "application/vnd.android.package-archive"); context.startActivity(intent);//from ww w.j a v a 2 s . c o m }
From source file:Main.java
/** * Install a given file via package installer * /*from ww w .j a va 2 s. c o m*/ * @param context * @param file */ public static void installFile(Context context, File file) { if (file != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } }
From source file:Main.java
public static void disImage(Activity act, File file) { Intent itt = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); itt.setData(Uri.fromFile(file));//from ww w . j a v a 2 s.c o m act.sendBroadcast(itt); Intent it = new Intent(Intent.ACTION_VIEW); it.setDataAndType(Uri.parse(file.getPath()), "image/*"); act.startActivity(it); }
From source file:Main.java
public static boolean installApp(Context context, File apkFile) { try {// w ww . java 2 s . c om Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); context.startActivity(intent); return true; } catch (Exception e) { return false; } }
From source file:Main.java
private static void installApk(Context context, Uri uri) { try {//from w ww .j av a2s . com Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.android.package-archive"); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); Toast.makeText(context, "DanaCast is out-dated, please visit http://danacast.me/", Toast.LENGTH_LONG) .show(); } }
From source file:Main.java
public static void installApk(Context context, String apkPath) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(apkPath)), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);/* www. j a v a 2 s . c om*/ }
From source file:Main.java
public static void installApkWithPrompt(File apkFile, Context context) { Intent promptInstall = new Intent(Intent.ACTION_VIEW); promptInstall.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); context.startActivity(promptInstall); }
From source file:Main.java
public static final void viewImageFromUri(Context ctx, Uri u) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(u, "image/*"); ctx.startActivity(intent);/*w ww .ja v a 2 s . c o m*/ }
From source file:Main.java
public static void install(Context context, File file) { try {//w ww . j ava 2 s . c o m Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }