List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static void launchUrl(String url, Context context) { if (!url.isEmpty() && context != null) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); }//from w w w .j a va 2s. com }
From source file:Main.java
public static void openGPS(Context context) { Log.d(TAG, "openGPS"); LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (!locationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) { Intent gpsIntent = new Intent(); gpsIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); gpsIntent.addCategory("android.intent.category.ALTERNATIVE"); gpsIntent.setData(Uri.parse("custom:3")); try {//from w w w . ja va 2 s. co m PendingIntent.getBroadcast(context, 0, gpsIntent, 0).send(); } catch (CanceledException e) { Log.d(TAG, "openGPS exception:" + e.getMessage()); e.printStackTrace(); } } }
From source file:Main.java
@TargetApi(16) static void setAndroidBeam(Activity activity, String packageName) { if (Build.VERSION.SDK_INT < 16) return;/*from w w w .ja v a 2 s.com*/ PackageManager pm = activity.getPackageManager(); NfcAdapter nfcAdapter = getAdapter(activity); if (nfcAdapter != null) { ApplicationInfo appInfo; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Uri uris[] = { Uri.parse("file://" + appInfo.publicSourceDir), }; nfcAdapter.setBeamPushUris(uris, activity); } catch (NameNotFoundException e) { e.printStackTrace(); } } }
From source file:Main.java
public static void shareFile(Context context, String title, String filePath) { Intent intent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.parse("file://" + filePath); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity(Intent.createChooser(intent, title)); }
From source file:Main.java
public static void openURL(Context context, String url) { Intent i = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)); context.startActivity(i);/*from w w w .j a va 2 s . c o m*/ }
From source file:Main.java
/** * Open Calendar app with specific time/* w w w . j a v a 2s. c o m*/ */ public static void openCalendar(Activity activity, long epochEventStartTime) { Uri uri = Uri.parse("content://com.android.calendar/time/" + epochEventStartTime); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); intent.putExtra("VIEW", "DAY"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); }
From source file:Main.java
private static Uri marketUri(String pkg) { return Uri.parse("market://details?id=" + pkg); }
From source file:Main.java
private static Uri homeUri(String pkg) { return Uri.parse("http://data.fbreader.org/android/packages/" + pkg + ".apk"); }
From source file:Main.java
public static String getGfycatId(String in) { Uri uri = Uri.parse(in); final String host = uri.getHost(); if (TextUtils.isEmpty(host) == false && host.endsWith("gfycat.com") == true) { List<String> paths = uri.getPathSegments(); if (paths.size() == 1) { return paths.get(0); } else if (paths.size() == 2) { return paths.get(1); }/*from w w w . java2s. c o m*/ } return null; }