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 installApk(Context context, String filePath) { File file = new File(filePath); if (!file.exists() || !file.isFile() || file.length() <= 0) { return false; }/*w w w . j av a 2 s. c om*/ 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); return true; }
From source file:Main.java
public static void pickImageFromPhotoForFragment(Fragment fragment, int requestCode) { Intent intent = new Intent(Intent.ACTION_PICK, null); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); fragment.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void pickImageFromPhoto(Activity activity, int requestCode) { Intent intent = new Intent(Intent.ACTION_PICK, null); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void chooseImg(Activity activity) { Intent pickIntent = new Intent(Intent.ACTION_PICK, null); pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); activity.startActivityForResult(pickIntent, PHOTO_REQUEST_GALLERY); }
From source file:Main.java
public static void jumpToSystemInstallApkActivity(Context context, String apkPath) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setDataAndType(Uri.fromFile(new File(apkPath)), "application/vnd.android.package-archive"); context.startActivity(intent);//from w w w. ja v a 2 s.com }
From source file:Main.java
public static Intent getHtmlFileIntent(String param) { Uri uri = Uri.parse(param).buildUpon().encodedAuthority("com.android.htmlfileprovider").scheme("content") .encodedPath(param).build(); Intent intent = new Intent("android.intent.action.VIEW"); intent.setDataAndType(uri, "text/html"); return intent; }
From source file:Main.java
public static boolean install(Context context, File file) { if (file == null || !file.exists() || !file.isFile()) { return false; }//from w w w.j a va 2 s . com Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return true; }
From source file:Main.java
private static Intent getHtmlFileIntent(File file) { Uri uri = Uri.parse(file.toString()).buildUpon().encodedAuthority("com.android.htmlfileprovider") .scheme("content").encodedPath(file.toString()).build(); Intent intent = new Intent("android.intent.action.VIEW"); intent.setDataAndType(uri, "text/html"); return intent; }
From source file:Main.java
public static void install(Context context, String path) { if (TextUtils.isEmpty(path)) { return;/* w w w .j av a2s . c o m*/ } Intent installIntent = new Intent(Intent.ACTION_VIEW); installIntent.setDataAndType(Uri.parse(path), "application/vnd.android.package-archive"); context.startActivity(installIntent); }
From source file:Main.java
public static boolean installApk(Context context, String fileName) { File apkfile = new File(fileName); if (!apkfile.exists()) { return false; }/*from ww w.j av a 2s . c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive"); context.startActivity(intent); return true; }