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 Intent getMarketIntent(Context context) { StringBuilder localStringBuilder = new StringBuilder().append("market://details?id="); String str = context.getPackageName(); localStringBuilder.append(str);/* w w w .ja v a 2 s .c o m*/ Uri localUri = Uri.parse(localStringBuilder.toString()); return new Intent(Intent.ACTION_VIEW, localUri); }
From source file:Main.java
/** * install an apk bu apkPath/*from w ww.j ava 2 s . c o m*/ * * @param context Context * @param apkPath apkPath */ public static final void installApk(Context context, String apkPath) { if (TextUtils.isEmpty(apkPath)) { return; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(new File(apkPath)), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
/** * Shortcut intent for icon on home screen. * @param url Url of the shortcut./* w w w . ja v a 2s . co m*/ * @return Intent for onclick action of the shortcut. */ public static Intent createShortcutIntent(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
public static void installApk(Context context, File file) { if (context != null && isFileExists(file)) { Uri uri = Uri.fromFile(new File(file.getAbsolutePath())); Intent installIntent = new Intent(); installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); installIntent.setAction(Intent.ACTION_VIEW); String type = "application/vnd.android.package-archive"; installIntent.putExtra("loadapk", "loadapk"); installIntent.setDataAndType(uri, type); context.startActivity(installIntent); }/*from w w w . j a v a 2s . c om*/ }
From source file:Main.java
static Intent createOpenCalendarAtDayIntent(Context context, DateTime goToTime) { Intent launchIntent = createCalendarIntent(Intent.ACTION_VIEW); Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath(TIME);/*from w w w .ja va 2 s .c o m*/ if (goToTime.getMillis() != 0) { launchIntent.putExtra(KEY_DETAIL_VIEW, true); ContentUris.appendId(builder, goToTime.getMillis()); } launchIntent.setData(builder.build()); return launchIntent; }
From source file:Main.java
/** * Open the google play store market with this app * //www . j av a 2 s.c o m * @param context the application context */ public static void openMarket(Context context) { Uri uri = Uri.parse("market://details?id=" + context.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { context.startActivity(goToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
/** * Launches to the specific app in the Android Marketplace. * * @param context Application or Activity context * @param action Desired action/*from w ww. j a v a2s .c om*/ */ public static void launchToMarketplace(final Context context, final String action) { final Uri intentUri = Uri.parse("market://search?q=pname:" + action); final Intent intent = new Intent(Intent.ACTION_VIEW, intentUri); context.startActivity(intent); }
From source file:Main.java
/** * Tries to open the app store by using the passed storeAppUri. If this * fails, opens the store website.//ww w . ja v a 2 s. c o m * * @param ctx The Android context. * @param storeAppUri The app store uri. * @param storeWebsiteUri The store website. */ public static void openAppStore(Context ctx, Uri storeAppUri, Uri storeWebsiteUri) { Intent marketIntent; try { marketIntent = new Intent(Intent.ACTION_VIEW, storeAppUri); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); ctx.startActivity(marketIntent); } catch (android.content.ActivityNotFoundException anfe) { marketIntent = new Intent(Intent.ACTION_VIEW, storeWebsiteUri); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); ctx.startActivity(marketIntent); } }
From source file:Main.java
public static void startReview(Context context) { Intent intent = new Intent(Intent.ACTION_VIEW, getReviewUri(context)); if (isIntentAvailable(context, intent)) { context.startActivity(intent);/*from w w w .j a v a2 s. c o m*/ setReviewDone(context, true); } else { setReviewDone(context, false); Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
/** * Starts Google Play application for this application. * @param context/*from w w w . j a va 2 s .c o m*/ */ public static void startGooglePlay(Context context) { final String appPackageName = context.getPackageName();// context.getPackageName(); // // // getPackageName() // from Context // or Activity // object try { context.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } }