List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static boolean deleteSms(Context context, String msgId) { LOGI("deleteSms " + msgId); try {/*from ww w.j av a2 s. c o m*/ context.getContentResolver().delete(Uri.parse("content://sms/" + msgId), null, null); return true; } catch (Exception e) { LOGE("deleteSms: " + e.getMessage()); e.printStackTrace(); return false; } }
From source file:Main.java
/** * Opens the device's browser to the passed url * @param activity the calling activity/*from www . j av a 2 s. c o m*/ * @param url the url to view */ public static void openBrowser(Activity activity, String url) { final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); activity.startActivity(Intent.createChooser(browserIntent, null)); }
From source file:Main.java
public static void callPhone(Context ctx, String phoneNumber) { if (ctx == null) { return;/*from ww w. jav a 2s . co m*/ } if (phoneNumber == null || phoneNumber.isEmpty()) { return; } Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); // ctx.startActivity(intent); }
From source file:Main.java
/** * @param activity//from w w w.j av a 2s .c o m * @param phone */ public static void phone(Activity activity, String phone) { phone = "tel:" + phone.trim(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(phone)); activity.startActivity(intent); }
From source file:Main.java
public static void startBrowser(Context context, String url) { try {//from w w w .ja v a 2 s.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) { } }
From source file:Main.java
/** * Returns an intent designated for the play store page for this application. * @param packageName - Package name of the application. * @return//from w w w .j a va 2s .c o m */ public static Intent getPlayStoreIntent(String packageName) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + packageName)); return intent; }
From source file:Main.java
public static boolean isExistShortcut(Activity context, String authorities) { boolean isInstallShortcut = false; final ContentResolver cr = context.getContentResolver(); final Uri CONTENT_URI = Uri.parse("content://" + authorities + "/favorites?notify=true"); Cursor c = cr.query(CONTENT_URI, new String[] { "iconPackage" }, "iconPackage=?", new String[] { context.getApplication().getPackageName() }, null); if (c != null) { if (c.getCount() > 0) { isInstallShortcut = true;//from w w w .jav a 2 s . co m } c.close(); } return isInstallShortcut; }
From source file:Main.java
public static Uri getUriFromPath(Context context, String path) { String fileName = "file:///sdcard/DCIM/Camera/2013_07_07_12345.jpg"; Uri fileUri = Uri.parse(fileName); String filePath = fileUri.getPath(); Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, "_data = '" + filePath + "'", null, null); cursor.moveToNext();// ww w .j a v a2 s.c o m int id = cursor.getInt(cursor.getColumnIndex("_id")); Uri uri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id); return uri; }
From source file:Main.java
public static void dialPhone(Context context, String phoneNumber) { if (!TextUtils.isEmpty(phoneNumber)) { try {/*w w w. j a va2s.c o m*/ Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)); context.startActivity(callIntent); } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
public static void callPhone(Context context, String phoneNumber) { if (!TextUtils.isEmpty(phoneNumber)) { try {/* w w w. j a va 2 s . c o m*/ Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); context.startActivity(callIntent); } catch (Exception e) { e.printStackTrace(); } } }