List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:Main.java
public static void downloadApkFromBrower(Context context, String url) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); Uri content_url = Uri.parse(url);/*from w ww .j a v a2s . c om*/ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(content_url); context.startActivity(intent); }
From source file:Main.java
public static void openAppDetails(Context context, String pkgname) { Intent i = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); Uri data = Uri.parse("package:" + pkgname); i.setData(data); context.startActivity(i);// w w w. j a v a2 s . c o m }
From source file:Main.java
public static void addImageToDeviceGallery(final Context context, final String imagePath) { final Intent mediaScanIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE"); final File f = new File(imagePath); final Uri contentUri = Uri.fromFile(f); mediaScanIntent.setData(contentUri); context.sendBroadcast(mediaScanIntent); }
From source file:Main.java
public static String unInstallBySys(Context context, String pckName) { Intent intent = new Intent(); Uri uri = Uri.parse("package:" + pckName); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_DELETE); intent.setData(uri); context.startActivity(intent);//from ww w . j a va 2 s .co m return null; }
From source file:Main.java
public static void shareOnTwitter(Context pContext, String urlToShare) { Intent tweetIntent = new Intent(Intent.ACTION_SEND); tweetIntent.putExtra(Intent.EXTRA_TEXT, urlToShare); tweetIntent.setType("text/plain"); PackageManager packManager = pContext.getPackageManager(); List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(tweetIntent, PackageManager.MATCH_DEFAULT_ONLY); boolean resolved = false; for (ResolveInfo resolveInfo : resolvedInfoList) { if (resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")) { tweetIntent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); resolved = true;//from w w w. j a va2 s . c o m break; } } if (resolved) { pContext.startActivity(tweetIntent); } else { Intent i = new Intent(); i.putExtra(Intent.EXTRA_TEXT, urlToShare); i.setAction(Intent.ACTION_VIEW); i.setData(Uri.parse("https://twitter.com/intent/tweet?text=message&via=profileName")); pContext.startActivity(i); } }
From source file:Main.java
private static void scanPhoto(Context ctx, String imgFileName) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File file = new File(imgFileName); Uri contentUri = Uri.fromFile(file); mediaScanIntent.setData(contentUri); ctx.sendBroadcast(mediaScanIntent);// ww w . j av a2 s .com }
From source file:Main.java
public static void openAppDetailSetting(Context context, String packageName) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromParts("package", packageName, null); intent.setData(uri); context.startActivity(intent);/* w ww . j a va2s . c om*/ }
From source file:Main.java
/** * Propose user to send an email with pre-filled fields. *///from w w w . j a v a 2 s.co m public static void sendEMail(final Context context, final String dialogTitle, final String to, final String subject, final String body) { final Intent send = new Intent(Intent.ACTION_SENDTO); final String uriText = "mailto:" + Uri.encode(to) + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(body); send.setData(Uri.parse(uriText)); context.startActivity(Intent.createChooser(send, dialogTitle)); }
From source file:net.reichholf.dreamdroid.intents.IntentFactory.java
/** * @param event/* w w w. j av a 2 s . c o m*/ */ public static void queryIMDb(Context context, ExtendedHashMap event) { Intent intent = new Intent(Intent.ACTION_VIEW); String uriString = "imdb:///find?q=" + event.getString(Event.KEY_EVENT_TITLE); intent.setData(Uri.parse(uriString)); try { context.startActivity(intent); } catch (ActivityNotFoundException anfex) { if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("mobile_imdb", false)) { uriString = "http://m.imdb.com/find?q=" + event.getString(Event.KEY_EVENT_TITLE); } else { uriString = "http://www.imdb.com/find?q=" + event.getString(Event.KEY_EVENT_TITLE); } intent.setData(Uri.parse(uriString)); context.startActivity(intent); } }
From source file:Main.java
public static void startBrowser(Context context, String url) { try {/*from w w w . j ava 2s .c o m*/ Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri content_url = Uri.parse(url); intent.setData(content_url); context.startActivity(intent); } catch (Exception e) { } }