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 Intent getImageFileIntent(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, "image/*"); return intent; }
From source file:Main.java
public static Intent getPptFileIntent(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/vnd.ms-powerpoint"); return intent; }
From source file:Main.java
public static Intent getChmFileIntent(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/x-chm"); return intent; }
From source file:Main.java
private static Intent getChmFileIntent(String filePath) { 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(filePath)); intent.setDataAndType(uri, "application/x-chm"); return intent; }
From source file:Main.java
private static Intent getWordFileIntent(String filePath) { 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(filePath)); intent.setDataAndType(uri, "application/msword"); return intent; }
From source file:Main.java
private static Intent getExcelFileIntent(String filePath) { 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(filePath)); intent.setDataAndType(uri, "application/vnd.ms-excel"); return intent; }
From source file:Main.java
private static Intent getImageFileIntent(String filePath) { 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(filePath)); intent.setDataAndType(uri, "image/*"); return intent; }
From source file:Main.java
private static Intent getIntentByType(String param, String type) { 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, type); return intent; }
From source file:Main.java
public static boolean installNormal(Context context, String filePath) { Intent intent = new Intent(Intent.ACTION_VIEW); File file = new File(filePath); if (file == null || !file.exists() || !file.isFile() || file.length() <= 0) { return false; } else {/*from w w w .j av a2 s .c o m*/ intent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return true; } }
From source file:Main.java
public static void openPDF(Context context, String path) { 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(path)); intent.setDataAndType(uri, "application/pdf"); try {/* w w w. j av a2s.c o m*/ context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }