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 getMediaIntent(String path) { Intent it = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse(path);//from w w w . j av a 2 s . com it.setDataAndType(uri, "audio/mp3"); return it; }
From source file:Main.java
public static void installAPK(Context context, String apkFile) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(apkFile)), "application/vnd.android.package-archive"); context.startActivity(intent);/* w ww. j a va 2 s . c o m*/ }
From source file:Main.java
public static boolean isCallable(Context context, String url) { String mimeTypeExtension = URLConnection.guessContentTypeFromName(url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url), mimeTypeExtension); List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
public static void installAPK(Context context, File apkFile) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); context.startActivity(intent);//from ww w . j a va 2 s.co m }
From source file:Main.java
public static Drawable getDrawableForMimetype(Uri uri, String str, Context context) { if (str == null) { return null; }/* www .ja v a 2s .c o m*/ PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent("android.intent.action.VIEW"); intent.setDataAndType(uri, str); List queryIntentActivities = packageManager.queryIntentActivities(intent, AccessibilityNodeInfoCompat.ACTION_CUT); return (queryIntentActivities == null || queryIntentActivities.size() <= 0) ? null : ((ResolveInfo) queryIntentActivities.get(queryIntentActivities.size() - 1)) .loadIcon(packageManager); }
From source file:Main.java
public static Intent getInstallIntent(File apkFile) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(apkFile.getAbsolutePath())), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; }
From source file:Main.java
public static Intent buildImageCropIntent(Uri uriFrom, Uri uriTo, int aspectX, int aspectY, int outputX, int outputY, boolean returnData) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uriFrom, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("output", uriTo); intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra("return-data", returnData); intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); return intent; }
From source file:Main.java
private static void cropImageUri(Uri uri, int outputX, int outputY, int requestCode, Activity activity) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra("return-data", false); intent.putExtra("scaleUpIfNeeded", true); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
/** * call system to install the APK file// ww w . jav a2 s . co m * */ public static void installAPKFile(Context context, File file) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static Intent getGalleryIntent() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); return intent; }