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 void installApk(Context context, String fileName) { if (fileName != null && fileName.contains(".apk")) { // File f = new File(fileName); // if(f.exists()){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file://" + fileName), "application/vnd.android.package-archive"); context.startActivity(intent);//from ww w . j a v a 2 s . com // } } }
From source file:Main.java
public static void getMoreApps(Context context, String publisherName) { Intent intent = new Intent(Intent.ACTION_VIEW, getMoreAppsUri(publisherName)); if (isIntentAvailable(context, intent)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);// w w w. j av a 2s .c om } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
public static void showOperaBrowser(Context context, String visitUrl) { Intent intent = new Intent(); intent.setClassName("com.opera.mini.android", "com.opera.mini.android.Browser"); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse(visitUrl)); context.startActivity(intent);/*from w w w .j a v a 2 s.co m*/ }
From source file:Main.java
/** * Returns import source uri based on the Intent. *//* ww w . ja va2s.co m*/ static Uri getImportUri(Intent intent) { String action = intent.getAction(); if (Intent.ACTION_SEND.equals(action)) { return intent.getParcelableExtra(Intent.EXTRA_STREAM); } if (Intent.ACTION_VIEW.equals(action)) { return intent.getData(); } return null; }
From source file:Main.java
/** * Install a given file via package installer * /* www . j av a 2s . c o m*/ * @param context * @param file */ public static void installFile(Context context, File file) { if (file != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } }
From source file:Main.java
/** * Starts Google Play Services in Play application. * @param context/*from w w w .j a v a 2 s .c om*/ */ public static void startGooglePlayServicesRefresh(Context context) { try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.google.android.gms"))); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void installAPK(Context context, File file) { if (file == null || !file.exists()) return;// w w w . j a va2 s.co m Intent intent = new Intent(); intent.setFlags(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
public static void link(Context context, String link) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); }
From source file:Main.java
public static void startWebIntent(Context context, String url) { try {/*from w w w . j av a 2 s .c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting url intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app for viewing this url!", Toast.LENGTH_SHORT) .show(); } }
From source file:Main.java
/** * use for oepn any url in browser.//from w w w . j a va 2s .c o m * * @param mContext * @param url to open in your mobile browser */ public static void openURL(Context mContext, String url) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent); }