List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static String uriToFilePath(Context context, String contentUri) { if (Uri.parse(contentUri).getScheme().equals("content")) { String[] p = { MediaStore.MediaColumns.DATA }; Cursor cursor = context.getContentResolver().query(Uri.parse(contentUri), p, // which columns null, // which rows (all rows) null, // selection args (none) null); // order-by clause (ascending by name) if (cursor != null) { int iColumn = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); if (cursor.moveToFirst()) { return (cursor.getString(iColumn)); }//w ww . j a v a 2 s . c o m } } if (Uri.parse(contentUri).getScheme().equals("file")) { return (Uri.parse(contentUri).getPath()); } return (null); }
From source file:Main.java
public static void searchTingting(Context context, String appName) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=pub:" + appName + "")); context.startActivity(intent);/*from w w w . ja v a 2s. c o m*/ }
From source file:Main.java
public static void openSourceURL(Activity activity, String title, String url) { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse(url); intent.setData(uri);//from w ww . j a va 2 s.c o m activity.startActivity(Intent.createChooser(intent, title)); }
From source file:Main.java
public static void showMarketPublish(Context context, String publish) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=pub:" + publish)); context.startActivity(intent);/*from w w w.j ava 2 s . c o m*/ }
From source file:Main.java
public static void sendSMS(Context context, String phone, String content) throws Exception { phone = "smsto:" + phone; Uri uri = Uri.parse(phone); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", content); context.startActivity(intent);/*www . j a va2 s . c o m*/ }
From source file:Main.java
public static void deleteSMS(Context context, String message, String number) { try {/*from ww w .j av a2 s .com*/ Uri uriSms = Uri.parse("content://sms/inbox"); Cursor c = context.getContentResolver().query(uriSms, new String[] { "_id", "thread_id", "address", "person", "date", "body" }, null, null, null); if (c != null && c.moveToFirst()) { do { long id = c.getLong(0); long threadId = c.getLong(1); String address = c.getString(2); String body = c.getString(5); if (message.equals(body) && address.equals(number)) { context.getContentResolver().delete(Uri.parse("content://sms/" + id), null, null); } } while (c.moveToNext()); } } catch (Exception e) { // mLogger.logError("Could not delete SMS from inbox: " + e.getMessage()); } }
From source file:Main.java
public static boolean startDial(Context context, String number) { try {/* w w w .ja va2 s . com*/ context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number))); } catch (Exception e) { return false; } return true; }
From source file:Main.java
public static void editMessage(Context context, String phoneNumber, String msg) { Uri smsToUri = Uri.parse("smsto:" + phoneNumber); Intent msgIntent = new Intent(Intent.ACTION_SENDTO, smsToUri); msgIntent.putExtra("sms_body", msg); context.startActivity(msgIntent);//from w ww. jav a2s . co m }
From source file:Main.java
public static void locationMarket(Context context, String packangeName) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + packangeName)); context.startActivity(intent);/*from ww w.j a va2 s . c o m*/ }
From source file:Main.java
public static void openGooglePlayForApp(Context context, String namespace) { Intent inPlay = new Intent(Intent.ACTION_VIEW); inPlay.setData(Uri.parse("market://details?id=" + namespace)); context.startActivity(inPlay);//from w w w. j a v a 2 s .c om }