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
public static List<ResolveInfo> getBrowsers(Context context) { PackageManager pm = context.getPackageManager(); Intent query = new Intent(); query.setAction(Intent.ACTION_VIEW); query.setData(Uri.parse("http://localhost")); return pm.queryIntentActivities(query, 0); }
From source file:Main.java
public static boolean isPlayStoreInstalled(Context context) { if (null == context) return false; try {/* w w w.j a v a 2 s . c om*/ Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=dummy")); PackageManager manager = context.getPackageManager(); List<ResolveInfo> list = manager.queryIntentActivities(market, 0); return list.size() > 0; } catch (Exception e) { return false; } }
From source file:Main.java
public static void startSmsIntent(Context context, String phoneNumber) { try {/*from ww w .ja v a2s . c om*/ Uri uri = Uri.parse("sms:" + phoneNumber); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.putExtra("address", phoneNumber); intent.setType("vnd.android-dir/mms-sms"); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting sms intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app to send an SMS!", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static boolean installApp(Context context, String filePath) { if (filePath != null && filePath.length() > 4 && filePath.toLowerCase().substring(filePath.length() - 4).equals(".apk")) { Intent intent = new Intent(Intent.ACTION_VIEW); File file = new File(filePath); if (file.exists() && file.isFile() && file.length() > 0) { intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return true; }/*from www .j a v a2 s. c o m*/ } return false; }
From source file:Main.java
public static void openBrowser(Context context, String url) { if (!TextUtils.isEmpty(url)) { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = "http://" + url; }//from w w w. ja va 2 s .com context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } else { Log.e("Helpers#openBrowser", "Something isn't right about the URL passed"); } }
From source file:Main.java
public static Intent getYoutubeTrailerIntent(String videoKey) { Uri videoUri = Uri.parse(YOUTUBE_PLAY_BASE_URL).buildUpon() .appendQueryParameter(YOUTUBE_VIDEO_KEY_PARAM, videoKey).build(); return new Intent(Intent.ACTION_VIEW, videoUri); }
From source file:Main.java
/** * <pre>//from w ww. ja va 2 s . c o m * Open other app to view URL of an app (typically browser or Google Play) * </pre> * @param downloadUrl */ public static void openDownloadPage(String downloadUrl) { Context context = getCurrentContext(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(downloadUrl)); context.startActivity(intent); }
From source file:Main.java
/** Opens Google Play Services in Google Play, if available. */ public static void openGooglePlayServicesInGooglePlay(final Context context) { Uri uri = Uri.parse("market://details?id=com.google.android.gms"); Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri); try {/*ww w . ja v a2s . c o m*/ context.startActivity(myAppLinkToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(context, "Unable to find app in Google Play", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static void installApk(Context context, File file) { if (context == null) return;/*from w w w .java 2 s . c om*/ if (file == null) return; Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 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 get more apps//from w w w. j a v a 2 s . c o m * * @param context * @param publisherName */ public static void getMoreApps(Context context, String publisherName) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:" + publisherName)); if (isIntentAvailable(context, intent)) { context.startActivity(intent); } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }