List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static void saveImageSendBroadcast(Activity activity, String filePath) { activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + filePath))); // com.hss01248.lib.activity. sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory()+ filePath))); }
From source file:Main.java
@NonNull public static Intent sendSms(@NonNull String to, @NonNull String message) { final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + to)); intent.putExtra("sms_body", message); return intent; }
From source file:Main.java
public static void call(String phoneNum, Context context) throws Exception {//TODO tobe test Intent intent = new Intent(); intent.setAction(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + phoneNum)); context.startActivity(intent);//from w w w .j a va 2 s. c om }
From source file:Main.java
public static Long getOrCreateThreadId(Context context, String phone) { try {/* www . ja v a 2 s. c o m*/ Uri threadIdUri = Uri.parse("content://mms-sms/threadID"); Uri.Builder builder = threadIdUri.buildUpon(); String[] recipients = { phone }; for (String recipient : recipients) { builder.appendQueryParameter("recipient", recipient); } Uri uri = builder.build(); Long threadId = 0L; Cursor cursor = context.getContentResolver().query(uri, new String[] { "_id" }, null, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { threadId = cursor.getLong(0); } } finally { cursor.close(); } return threadId; } } catch (Exception e) { e.printStackTrace(); } return -1L; }
From source file:Main.java
public static void installApp(Context context, String path) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file://" + path), "application/vnd.android.package-archive"); context.startActivity(intent);//from w w w . jav a 2s . c o m }
From source file:Main.java
/** * uninstall app via package name//from w ww . j a v a 2 s . c om * @param context * @param packageName */ public static void uninstallApp(Context context, String packageName) { Uri packageUri = Uri.parse("package:" + packageName); Intent intent = new Intent(); intent.setAction(Intent.ACTION_DELETE); intent.setData(packageUri); context.startActivity(intent); }
From source file:Main.java
public static void playVideo(String url, Activity activity) { if (url != null && url.length() > 0) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url), "video/*"); activity.startActivity(intent);//from w w w . j a v a2 s .co m } }
From source file:Main.java
public static void requestGooglePlay(Activity activity, String packageName) { try {//from w w w . jav a 2s . c o m activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName))); } catch (android.content.ActivityNotFoundException anfe) { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageName))); } }
From source file:Main.java
public static void mail(Activity activity, String subject, String text, String mail) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:" + mail)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); activity.startActivity(intent);//from www . j a v a 2 s . co m }
From source file:Main.java
public static void jumpTo(Activity activity, String url) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); activity.startActivity(intent);/*from w w w. j a v a2 s . c o m*/ }