List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static boolean playAudio(Context context, String mrl, String name) { try {// ww w .j a v a2s.c o m Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(mrl), "audio/*"); context.startActivity(intent); return true; } catch (android.content.ActivityNotFoundException ex) { } return false; }
From source file:Main.java
public static void uninstallApk(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_VIEW); Uri data = Uri.parse("package:" + packageName); intent.setData(data);/*from w w w. ja va2s . com*/ context.startActivity(intent); }
From source file:Main.java
public static long uriFileSize(Context context, String contentUri) { long result = 0; Uri uri = Uri.parse(contentUri); if (!uri.getScheme().equals("content")) { return (fileUriFileSize(context, contentUri)); }/* ww w . ja v a 2 s . co m*/ String[] p = { MediaStore.MediaColumns.SIZE }; Cursor cursor = context.getContentResolver().query(uri, 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.SIZE); if (cursor.moveToFirst()) { result = cursor.getLong(iColumn); } } return (result); }
From source file:Main.java
public static void doCall(Activity aty, String mobile) throws Exception { if (null != aty && null != mobile) { Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + mobile)); phoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); aty.startActivity(phoneIntent);/* ww w .ja va 2s .co m*/ } }
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); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(content_url);/*from ww w. j a va 2s .c o m*/ context.startActivity(intent); }
From source file:Main.java
public static void sendSmsBySystem(Context context, String phone, String body) { if (TextUtils.isEmpty(phone)) return;/* w w w . j a v a 2 s .c o m*/ Uri uri = Uri.parse("smsto:" + phone); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", body); context.startActivity(intent); }
From source file:Main.java
/** * //from w w w .j a v a 2s . co m * @param activity * @param url */ public static void openBrowserWithUrl(Activity activity, String url) { Intent openBrowserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); activity.startActivity(openBrowserIntent); }
From source file:Main.java
public static void accessUrl(Context context, String url) { Intent intent = new Intent(Intent.ACTION_VIEW); //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(url)); context.startActivity(intent);/* ww w .ja va2s . c om*/ }
From source file:Main.java
public static void shareViaEmail(Context context, String subject, String text) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType("text/html"); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_SUBJECT, subject); context.startActivity(Intent.createChooser(intent, "Share via Email")); }
From source file:Main.java
public static Intent newMapIntent_LatLong(Context context, double lat, double lng) { String uri = String.format("geo:%f,%f", lat, lng); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); return intent; }