List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:Main.java
/** * @deprecated/* ww w . j a va2 s . c o m*/ * use isGooglePlayInstalled(Context ctx) instead * @param ctx * @return */ public static boolean isAndroidMarketInstalled(Context ctx) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=foo")); PackageManager pm = ctx.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent, 0); if (list.size() > 0) { return true; } else { return false; } }
From source file:Main.java
public static void openURL(Context ctx, String url) { Intent i2 = new Intent(Intent.ACTION_VIEW); i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i2.setData(Uri.parse(url)); ctx.startActivity(i2);// w ww.j a v a 2 s . c om }
From source file:Main.java
public static void uninstallApk(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_DELETE); Uri packageURI = Uri.parse("package:" + packageName); intent.setData(packageURI); context.startActivity(intent);/*w ww . j ava 2 s . c o m*/ }
From source file:Main.java
/** * Launches the Play Store product page for the specified package name * * @param context// w ww.j a va2s . c o m * @param packageName The package name of the app */ public static void launchPlayStoreProductPage(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_VIEW); try { intent.setData(Uri.parse("market://details?id=" + packageName)); context.startActivity(intent); } catch (ActivityNotFoundException e) { intent.setData(Uri.parse("http://play.google.com/store/apps/details?id=" + packageName)); context.startActivity(intent); } }
From source file:Main.java
@Deprecated public static void uninstallApk2(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_DELETE); Uri packageURI = Uri.parse("package:" + packageName); intent.setData(packageURI); context.startActivity(intent);//from w w w. j a v a 2 s . co m }
From source file:Main.java
public static void installApk(Context context, File filename) { Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.fromFile(filename)); context.startActivity(intent);/* ww w .j a v a 2 s . c o m*/ }
From source file:Main.java
public static Intent newTelIntent(String telurl) { Intent intent = new Intent(Intent.ACTION_DIAL); // FIXME : need to check XXX is really a short number in tel:XXX intent.setData(Uri.parse(telurl)); return intent; }
From source file:Main.java
public static void insertImageToPhotoAlbum(Context context, String fileName) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(fileName)); intent.setData(uri); context.sendBroadcast(intent);/* www . ja v a2s. c o m*/ }
From source file:Main.java
public static void scanPhotos(String filePath, Context context) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(filePath)); intent.setData(uri); context.sendBroadcast(intent);/*from w ww . j a v a 2 s. co m*/ }
From source file:Main.java
public static void showWebPage(Context context, String url) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); Uri uri = Uri.parse(url);//w w w . jav a 2s . c o m intent.setData(uri); context.startActivity(intent); }