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 boolean installApk(Context context, String filePath) { File file = new File(filePath); if (!file.exists() || !file.isFile() || file.length() <= 0) { return false; }//www . j a v a 2 s .c o m Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); return true; }
From source file:Main.java
public static void launchAppMarket(Context context, String pkgname) { Uri uri = Uri.parse("market://details?id=" + pkgname); // uri = Uri.parse("market://details?id=" + "com.tencent.mobileqq"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);//www . j a v a2s. com }
From source file:Main.java
public static void callGoogleTranslateApps(Context context, String word, String toLang) { try {//from ww w . jav a2 s . com Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.putExtra("key_text_input", word); i.putExtra("key_text_output", ""); i.putExtra("key_language_from", "en"); i.putExtra("key_language_to", "vi"); i.putExtra("key_suggest_translation", ""); i.putExtra("key_from_floating_window", false); i.setComponent(new ComponentName("com.google.android.apps.translate", "com.google.android.apps.translate.TranslateActivity")); context.startActivity(i); } catch (ActivityNotFoundException ex) { Toast.makeText(context, "Google translate app is not installed", Toast.LENGTH_SHORT).show(); ex.printStackTrace(); } }
From source file:Main.java
public static void openSetting(Activity activity, int requestCode) { Intent intent = new Intent("/"); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm);/* w w w . j a v a 2s . c o m*/ intent.setAction(Intent.ACTION_VIEW); activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void installApk(Context context, String apkUrl) { File file = new File(apkUrl); if (!file.exists()) return;/*from w ww .j a v a 2s. com*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse(apkUrl), type); context.startActivity(intent); }
From source file:Main.java
public static void install(Context context, String fileName) { if (TextUtils.isEmpty(fileName) || context == null) { return;/*from ww w .ja va 2 s . c o m*/ } try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive"); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
/** * use to show address location pin on map. * * @param mContext/*from w w w . j a v a 2s . c o m*/ * @param address to show on map. */ public static void showAddressOnMap(Context mContext, String address) { address = address.replace(' ', '+'); Intent geoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address)); mContext.startActivity(geoIntent); }
From source file:Main.java
public static Intent createOpenCalendarEventIntent(int eventId, DateTime from, DateTime to) { Intent intent = createCalendarIntent(Intent.ACTION_VIEW); intent.setData(ContentUris.withAppendedId(Events.CONTENT_URI, eventId)); intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, from.getMillis()); intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, to.getMillis()); return intent; }
From source file:Main.java
/** * install app//from w w w . j a v a 2 s . c om * * @param context * @param filePath * @return whether apk exist */ public static boolean install(Context context, String filePath) { Intent i = new Intent(Intent.ACTION_VIEW); File file = new File(filePath); if (file != null && file.length() > 0 && file.exists() && file.isFile()) { i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); return true; } return false; }
From source file:Main.java
public static Intent getComponentIntent(String packageName, String className, Bundle bundle) { Intent intent = new Intent(Intent.ACTION_VIEW); if (bundle != null) intent.putExtras(bundle);/* w w w .ja v a2 s. c o m*/ ComponentName cn = new ComponentName(packageName, className); intent.setComponent(cn); return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }