List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static void openPlayStore(Context context) { final String appPackageName = context.getPackageName(); try {/*from www.j av a 2 s. c o m*/ 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))); } }
From source file:Main.java
public static Intent getIntent(Context paramContext) { StringBuilder localStringBuilder = new StringBuilder().append("market://details?id="); String str = paramContext.getPackageName(); localStringBuilder.append(str);// w w w . j a va2 s . c o m Uri localUri = Uri.parse(localStringBuilder.toString()); return new Intent("android.intent.action.VIEW", localUri); }
From source file:Main.java
public static void startSmsIntent(Context context, String phoneNumber) { try {/* w w w.j a v a 2 s . c om*/ Uri uri = Uri.parse("sms:" + phoneNumber); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.putExtra("address", phoneNumber); intent.setType("vnd.android-dir/mms-sms"); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting sms intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app to send an SMS!", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
/** * Convert R id into a Uri which can be used for pushing that image etc to the UI * * @param resourceId//from www. j a v a 2s .c o m * @return */ @NonNull public static Uri getResourceUri(@NonNull final int resourceId) { return Uri.parse("android.resource://com.futurice.vor/" + resourceId); }
From source file:Main.java
@Nullable public static Uri safeUri(@NonNull String url) { if (TextUtils.isEmpty(url)) { return null; }/*from w ww . j av a2 s . c o m*/ Uri uri = Uri.parse(url); if (TextUtils.isEmpty(uri.getScheme()) || TextUtils.isEmpty(uri.getHost())) { return null; } return uri; }
From source file:Main.java
/** * @param artistName// w w w . j a va 2 s .c o m */ public static void shopFor(Context mContext, String artistName) { String str = "https://market.android.com/search?q=%s&c=music&featured=MUSIC_STORE_SEARCH"; Intent shopIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(str, Uri.encode(artistName)))); shopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shopIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); mContext.startActivity(shopIntent); }
From source file:Main.java
/** ----------------------------------------------------------------------- Google Maps -- */ public static Intent newOpenMapsAtLatLongAndName(String latitude, String longitude, String name) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.ENGLISH, "geo:%s,%s", latitude, longitude) + "?q=" + Uri.encode(latitude + "," + longitude + "(" + name + ")") + "&z=16")); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); return intent; }
From source file:Main.java
public static String FromCameraResult(Intent data, Context context, File file) { try {/* w ww . ja v a2 s . c o m*/ if (file != null) { Uri u = Uri.parse(MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), null, null)); return getPathFromUri(context, u); } } catch (Exception e) { return null; } return null; }
From source file:Main.java
public static boolean gotoGoogleMarket(Activity activity, String pck) { try {//from w ww.ja va2 s . com Intent intent = new Intent(); intent.setPackage("com.android.vending"); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + pck)); activity.startActivity(intent); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:Main.java
public static void toMarket(Context context) { try {/* ww w.j a v a 2s . co m*/ context.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName()))); } catch (android.content.ActivityNotFoundException e) { Log.e(TAG, "market can't open " + e); } }