List of usage examples for android.content Intent setDataAndType
public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type)
From source file:Main.java
private static Intent getAudioFileIntent(File file) { 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(file);/*from ww w .j a v a 2 s .c om*/ intent.setDataAndType(uri, "audio/*"); return intent; }
From source file:Main.java
private static Intent getVideoFileIntent(File file) { 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(file);/*from w w w . j av a2 s .c o m*/ intent.setDataAndType(uri, "video/*"); return intent; }
From source file:Main.java
public static void installApk(Context context, File file) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.setType("application/vnd.android.package-archive"); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);/*from ww w . ja v a2s .c om*/ }
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 void openImage(Context mContext, String imagePath) { 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(imagePath)); intent.setDataAndType(uri, "image/*"); mContext.startActivity(intent);/*from w w w .j a va 2s .com*/ }
From source file:Main.java
public static Intent getVideoFileIntent(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, "video/*"); return intent; }
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 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
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 installApk(Context context, File file) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.setType("application/vnd.android.package-archive"); intent.setData(Uri.fromFile(file));//from w w w . ja v a 2s .c o m intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }