List of usage examples for android.content Intent ACTION_VIEW
String ACTION_VIEW
To view the source code for android.content Intent ACTION_VIEW.
Click Source Link
From source file:Main.java
/** * Shortcut intent for icon on homescreen. * @param context Context used to create the intent. * @param url Url of the bookmark./*from w w w. j a v a2s. com*/ * @return Intent for onclick action of the shortcut. */ public static Intent createShortcutIntent(Context context, String url) { Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); shortcutIntent.putExtra(REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); return shortcutIntent; }
From source file:Main.java
/** * Checks if there is any of the CFI apps installed on the device supports PBBA payment. * * @param context application context// w w w . j av a 2 s.c o m * @return true if available */ public static boolean isZappCFIAppAvailable(@NonNull final Context context) { final Intent zappIntent = new Intent(); zappIntent.setAction(Intent.ACTION_VIEW); zappIntent.setData(new Uri.Builder().scheme(ZAPP_SCHEME).build()); final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(zappIntent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo != null; }
From source file:Main.java
/** * This method queries the system to check if there is a viewer available or not. If no suitable viewer is * found, this method returns false./* ww w.j a v a 2 s. co m*/ * @return True if PDF viewer is available, false otherwise. */ public static boolean isViewerAvailable(Context context, Uri uri) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
public static Intent getOpenFileIntent(File file) { if (file == null || !file.exists() || !file.isFile()) { return null; }/*w ww. j a v a 2 s .c o m*/ String extension = MimeTypeMap.getFileExtensionFromUrl(file.getAbsolutePath()); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (extension == null || mimeType == null) { return null; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), mimeType); return intent; }
From source file:Main.java
public static void goToInstalledAppDetails(Context context, String packageName) { Intent intent = new Intent(); int sdkVersion = Build.VERSION.SDK_INT; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.fromParts("package", packageName, null)); } else {//from w w w.j a v a 2 s . com intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra( (sdkVersion == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName"), packageName); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
/** * call system to install the APK file// w w w. j a v a 2s .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 void install(Context context, String apkFilePath) { if (context == null) { throw new RuntimeException("ApkUtils install apk method and parameter context == null?"); }//from ww w. java 2 s . c o m File file = new File(apkFilePath); if (!file.exists()) { return; } Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
/** * Method to send review//from w ww . j a v a2 s .c om * * @param context */ public static void sendReview(Context context) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())); if (isConnectionAvailable(context) && isIntentAvailable(context, intent)) { // SET THAT REVIEW IS DONE SharedPreferences sharedPreferences = context.getSharedPreferences(REVIEW_DONE, Context.MODE_PRIVATE); Editor edit = sharedPreferences.edit(); edit.putBoolean(REVIEW_DONE, true); edit.commit(); // START REVIEW ACTIVITY context.startActivity(intent); } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
private static void showAppInMarket(Context context, String desiredPackageName) { String url = ""; try {/*from w w w. j a v a 2s. c om*/ //Check whether Google Play store is installed or not: context.getPackageManager().getPackageInfo("com.android.vending", 0); url = "market://details?id=" + desiredPackageName; } catch (final Exception e) { url = "https://play.google.com/store/apps/details?id=" + desiredPackageName; } //Open the app page in Google Play store: final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
/** * Method to open app//from w w w. j a v a 2 s . com * * @param context */ public static void openApp(Context context, String appPackage) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackage)); if (isConnectionAvailable(context) && isIntentAvailable(context, intent)) { // SET THAT REVIEW IS DONE SharedPreferences sharedPreferences = context.getSharedPreferences(REVIEW_DONE, Context.MODE_PRIVATE); Editor edit = sharedPreferences.edit(); edit.putBoolean(REVIEW_DONE, true); edit.commit(); // START REVIEW ACTIVITY context.startActivity(intent); } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }