List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static boolean isShortCutExist(Context context) { boolean isExist = false; int version = android.os.Build.VERSION.SDK_INT; Uri uri = null;/*from w w w . j ava 2 s . c o m*/ if (version < 2.0) { uri = Uri.parse("content://com.android.launcher.settings/favorites"); } else { uri = Uri.parse("content://com.android.launcher2.settings/favorites"); } String selection = " title = ?"; String[] selectionArgs = new String[] { "YouTube" }; Cursor c = context.getContentResolver().query(uri, null, selection, selectionArgs, null); if (c != null && c.getCount() > 0) { isExist = true; } if (c != null) { c.close(); } return isExist; }
From source file:Main.java
public static Intent getSmsIntent(String number, String body) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("smsto:" + number)); intent.putExtra("sms_body", body); return intent; }
From source file:Main.java
/** Opens Google Play Services in Google Play, if available. */ public static void openGooglePlayServicesInGooglePlay(final Context context) { Uri uri = Uri.parse("market://details?id=com.google.android.gms"); Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri); try {//from w w w . ja v a 2 s.c o m context.startActivity(myAppLinkToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(context, "Unable to find app in Google Play", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static boolean installApk(Context context, String archiveFilePath) { try {/*from w w w . j a v a 2 s. co m*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file:///" + archiveFilePath), "application/vnd.android.package-archive"); context.startActivity(intent); return true; } catch (Exception e) { return false; } }
From source file:Main.java
public static void launchWeb(Context activityContext, String url) { //Log.d(TAG, "launchWeb::"+url); Intent in = new Intent(); in.setAction(Intent.ACTION_VIEW);/* w w w .ja v a2s. co m*/ in.addCategory(Intent.CATEGORY_BROWSABLE); in.setData(Uri.parse(url)); activityContext.startActivity(in); }
From source file:Main.java
public static void intallApk(Context context, String filePath) { File apkfile = new File(filePath); if (!apkfile.exists()) return;/* w ww. java2 s . c o m*/ Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive"); context.startActivity(i); }
From source file:Main.java
public static void callPhone(Context ctx, String phoneNumber) { if (ctx == null) { return;//from w w w. j a v a2 s. co m } if (phoneNumber.isEmpty()) { return; } Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); ctx.startActivity(intent); }
From source file:Main.java
@Nullable static Uri safeUri(@NonNull String url) { if (TextUtils.isEmpty(url)) { return null; }// ww w. ja v a 2 s. c o m Uri uri = Uri.parse(url); if (uri.getHost() == null || uri.getScheme() == null) { return null; } return uri; }
From source file:Main.java
public static void install(Context context, String path) { if (TextUtils.isEmpty(path)) { return;/*from w ww . j a v a 2 s. c o m*/ } Intent installIntent = new Intent(Intent.ACTION_VIEW); installIntent.setDataAndType(Uri.parse(path), "application/vnd.android.package-archive"); context.startActivity(installIntent); }
From source file:Main.java
public static void sendSmsByPhoneAndContext(Context context, String phone, String content) { phone = TextUtils.isEmpty(phone) ? "" : phone; content = TextUtils.isEmpty(content) ? "" : content; Uri uri = Uri.parse("smsto:" + phone); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", content); context.startActivity(intent);/*from w w w . j a v a2 s. co m*/ }