List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static Intent getMarketIntent(Context context) { StringBuilder localStringBuilder = new StringBuilder().append("market://details?id="); String str = context.getPackageName(); localStringBuilder.append(str);//from ww w. jav a 2 s . co m Uri localUri = Uri.parse(localStringBuilder.toString()); return new Intent(Intent.ACTION_VIEW, localUri); }
From source file:Main.java
/** * Checks to see if URL is DuckDuckGo SERP * Returns the query if it's a SERP, otherwise null * //from ww w .ja va2 s .c o m * @param url * @return */ static public String getQueryIfSerp(String url) { if (!isSerpUrl(url)) { return null; } Uri uri = Uri.parse(url); String query = uri.getQueryParameter("q"); if (query != null) return query; String lastPath = uri.getLastPathSegment(); if (lastPath == null) return null; if (!lastPath.contains(".html")) { return lastPath.replace("_", " "); } return null; }
From source file:Main.java
/** * Starts Google Play Services in Play application. * @param context/* w w w . j a v a2 s . c om*/ */ public static void startGooglePlayServicesRefresh(Context context) { try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.google.android.gms"))); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void installApkFromLocalPath(Activity activity, String apkname) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(//from w w w . ja v a 2 s. com Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/ewgvip/" + apkname), "application/vnd.android.package-archive"); activity.startActivity(intent); }
From source file:Main.java
/** * use to show address location pin on map. * * @param mContext// ww w. ja v a2 s .c o m * @param address to show on map. */ public static void showAddressOnMap(Context mContext, String address) { address = address.replace(' ', '+'); Intent geoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address)); mContext.startActivity(geoIntent); }
From source file:Main.java
public static void callPhone(Context ctx, String phoneNumber) { if (ctx == null) { return;//from ww w .ja v a2 s .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
public static String getSmsText(Context context, String msgId) { String result = null;/*from w w w . j av a 2s . c o m*/ try { Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[] { "body", }, "_id = ?", new String[] { msgId, }, null); if (c.moveToFirst()) { result = c.getString(0); } c.close(); } catch (Throwable t) { LOGE("getSmsText: " + t.getMessage()); t.printStackTrace(); result = null; } return result; }
From source file:Main.java
/** * Opens the dialer app with my number/* ww w . ja va 2s . com*/ * @param activity the calling activity * @param phoneNumber the phone number to call */ public static void openPhoneDialer(Activity activity, String phoneNumber) { Intent phoneIntent = new Intent(Intent.ACTION_DIAL); phoneIntent.setData(Uri.parse("tel:" + phoneNumber)); activity.startActivity(phoneIntent); }
From source file:Main.java
public static boolean startActivityUsingScheme(Activity a, String scheme, Bundle args) { Uri uri = Uri.parse(scheme + "://"); Intent intent = new Intent(Intent.ACTION_RUN, uri); boolean result = true; try {//ww w . j av a 2s .co m intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (args != null) intent.putExtras(args); a.startActivity(intent); } catch (Exception e) { Log.e(a.getClass().getName(), e.getMessage(), e); result = false; } return result; }
From source file:Main.java
public static void callSystemSmsAction(Context context, String phone, String content) { Uri uri = Uri.parse("smsto:" + (TextUtils.isEmpty(phone) ? "" : phone)); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", TextUtils.isEmpty(content) ? "" : content); context.startActivity(intent);//from w w w.j a v a2s. c om }