List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static Intent sendEmail(String[] to, String subject, String body) { final Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); return intent; }
From source file:Main.java
public static void refreshContent(Context context, String path) { Uri data = Uri.parse("file://" + path); context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, data)); }
From source file:Main.java
public static boolean hasPermission(Context context, String permissionType) { Uri uri = Uri.parse("content://com.google.atap.tango.PermissionStatusProvider/" + permissionType); Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); if (cursor == null) { return false; } else {//from w w w .j av a2 s.c o m return true; } }
From source file:Main.java
public static Intent pickContact(String with) { final Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://com.android.contacts/contacts")); if (!TextUtils.isEmpty(with)) { intent.setType(with);/*from w ww . j a v a2s .c o m*/ } return intent; }
From source file:Main.java
public static boolean checkShortCut(Context context, String appName) { boolean hasShortCut = false; try {/* w w w . j ava 2 s .c om*/ ContentResolver cr = context.getContentResolver(); final String AUTHORITY1 = "com.android.launcher.settings"; final String AUTHORITY2 = "com.android.launcher2.settings"; String contentUri = ""; if (android.os.Build.VERSION.SDK_INT < 8) { contentUri = "content://" + AUTHORITY1 + "/favorites?notify=true"; } else { contentUri = "content://" + AUTHORITY2 + "/favorites?notify=true"; } final Uri CONTENT_URI = Uri.parse(contentUri); Cursor c = cr.query(CONTENT_URI, new String[] { "title", "iconResource" }, "title=?", new String[] { appName }, null); if (c != null && c.getCount() > 0) { hasShortCut = true; } } catch (Exception e) { } return hasShortCut; }
From source file:Main.java
public static void openBrowser(Context context, String url) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); context.startActivity(intent);/*from ww w . j a v a2 s . co m*/ }
From source file:Main.java
public static Intent getSysAppSearchIntent(String key) { return new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=" + key)); }
From source file:Main.java
private static AlertDialog showDownloadDialog(final Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo, final String uriString) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); downloadDialog.setTitle(stringTitle); downloadDialog.setMessage(stringMessage); downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Uri uri = Uri.parse(uriString); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activity.startActivity(intent); }// w w w. j a va 2 s . c o m }); downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:Main.java
public static void openUrl(Context pContext, String pUrl) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pUrl)); pContext.startActivity(browserIntent); }
From source file:Main.java
/** * Play video file from res folder./*from w w w . ja va 2s. c o m*/ * Then call video.start(); * @param activity - current Activity * @param videoViewId R.id.introVideo * @param videoResourceId R.raw.intro - res/raw/intro.mp4 * @return VideoView */ public static VideoView playVideo(Activity activity, int videoViewId, int videoResourceId, MediaPlayer.OnCompletionListener listener) { activity.getWindow().setFormat(PixelFormat.TRANSLUCENT); VideoView view = (VideoView) activity.findViewById(videoViewId); view.setVideoURI( Uri.parse("android.resource://" + activity.getPackageName() + File.separator + videoResourceId)); view.setKeepScreenOn(true); view.setMediaController(null); view.setOnCompletionListener(listener); view.requestFocus(); return view; }