List of usage examples for android.content Intent setDataAndType
public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type)
From source file:com.amaze.carbonfilemanager.utils.files.Futils.java
private boolean isSelfDefault(File f, Context c) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(f), MimeTypes.getMimeType(f)); String s = ""; ResolveInfo rii = c.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (rii != null && rii.activityInfo != null) s = rii.activityInfo.packageName; return s.equals("com.amaze.carbonfilemanager") || rii == null; }
From source file:com.amaze.filemanager.utils.files.Futils.java
private boolean isSelfDefault(File f, Context c) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(f), MimeTypes.getMimeType(f)); String s = ""; ResolveInfo rii = c.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (rii != null && rii.activityInfo != null) s = rii.activityInfo.packageName; return s.equals("com.amaze.filemanager") || rii == null; }
From source file:com.ccxt.whl.activity.SettingsFragmentC_0815.java
/** * ?//w w w. j a v a2 s .co m * @param uri * @param outputX * @param outputY * @param requestCode */ private void cropImageUri(Uri uri, int outputX, int outputY, int requestCode) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); //aspectX aspectY intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); // outputX outputY ? intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra("return-data", false); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection startActivityForResult(intent, requestCode); }
From source file:com.android.contacts.common.model.ContactLoader.java
/** * Posts a message to the contributing sync adapters that have opted-in, notifying them * that the contact has just been loaded *///from w w w . j a va 2s. c o m private void postViewNotificationToSyncAdapter() { Context context = getContext(); for (RawContact rawContact : mContact.getRawContacts()) { final long rawContactId = rawContact.getId(); if (mNotifiedRawContactIds.contains(rawContactId)) { continue; // Already notified for this raw contact. } mNotifiedRawContactIds.add(rawContactId); final AccountType accountType = rawContact.getAccountType(context); final String serviceName = accountType.getViewContactNotifyServiceClassName(); final String servicePackageName = accountType.getViewContactNotifyServicePackageName(); if (!TextUtils.isEmpty(serviceName) && !TextUtils.isEmpty(servicePackageName)) { final Uri uri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); final Intent intent = new Intent(); intent.setClassName(servicePackageName, serviceName); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(uri, RawContacts.CONTENT_ITEM_TYPE); try { context.startService(intent); } catch (Exception e) { Log.e(TAG, "Error sending message to source-app", e); } } } }
From source file:io.ingame.squarecamera.CameraLauncher.java
/** * Brings up the UI to perform crop on passed image URI * * @param picUri//from w w w .j a va 2 s .c om */ private void performCrop(Uri picUri) { try { Intent cropIntent = new Intent("com.android.camera.action.CROP"); // indicate image type and Uri cropIntent.setDataAndType(picUri, "image/*"); // set crop properties cropIntent.putExtra("crop", "true"); // indicate output X and Y if (targetWidth > 0) { cropIntent.putExtra("outputX", targetWidth); } if (targetHeight > 0) { cropIntent.putExtra("outputY", targetHeight); } if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { cropIntent.putExtra("aspectX", 1); cropIntent.putExtra("aspectY", 1); } // create new file handle to get full resolution crop croppedUri = Uri.fromFile(new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg")); cropIntent.putExtra("output", croppedUri); // start the activity - we handle returning in onActivityResult if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, cropIntent, CROP_CAMERA); } } catch (ActivityNotFoundException anfe) { Log.e(LOG_TAG, "Crop operation not supported on this device"); // Send Uri back to JavaScript for viewing image this.callbackContext.success(picUri.toString()); } }
From source file:com.cordova.photo.CameraLauncher.java
/** * Brings up the UI to perform crop on passed image URI * /*from w w w. j a va 2s .c om*/ * @param picUri */ private void performCrop(Uri picUri) { try { Intent cropIntent = new Intent("com.android.camera.action.CROP"); // indicate image type and Uri cropIntent.setDataAndType(picUri, "image/*"); // set crop properties cropIntent.putExtra("crop", "true"); // indicate output X and Y if (targetWidth > 0) { cropIntent.putExtra("outputX", targetWidth); } if (targetHeight > 0) { cropIntent.putExtra("outputY", targetHeight); } if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { cropIntent.putExtra("aspectX", 1); cropIntent.putExtra("aspectY", 1); } // create new file handle to get full resolution crop croppedUri = Uri.fromFile(new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg")); cropIntent.putExtra("output", croppedUri); // start the activity - we handle returning in onActivityResult if (this.activity != null) { this.activity.startActivityForResult(cropIntent, CROP_CAMERA); } } catch (ActivityNotFoundException anfe) { Log.e(LOG_TAG, "Crop operation not supported on this device"); // Send Uri back to JavaScript for viewing image this.callbackContext.success(picUri.toString()); } }
From source file:com.custom.music.MusicBrowserActivity.java
/** * get current view//from w w w .ja va 2s . c o m * * @param index * @return View */ private View getView(int index) { Log.i(TAG, ">>> getView index = " + index, Log.APP); View view = null; Intent intent = new Intent(Intent.ACTION_PICK); //update by zjw //Uri.EMPTY --> custom switch (index) { case ARTIST_INDEX: intent.setClass(this, ArtistAlbumBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.ARTIST_MIME_TYPE); break; case ALBUM_INDEX: intent.setClass(this, AlbumBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.ALBUM_MIME_TYPE); break; case SONG_INDEX: intent.setClass(this, TrackBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.TRACK_MIME_TYPE); break; case PLAYLIST_INDEX: intent.setClass(this, PlaylistBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.PLAYLIST_MIME_TYPE); break; default: return null; } intent.putExtra("withtabs", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); view = mActivityManager.startActivity(getStringId(index), intent).getDecorView(); Log.i(TAG, "getView >>>", Log.APP); return view; }
From source file:com.imaginamos.taxisya.taxista.activities.RegisterDriverActivity.java
private void performCrop() { //call the standard crop action intent (the user device may not support it) Intent cropIntent = new Intent("com.android.camera.action.CROP"); //indicate image type and Uri cropIntent.setDataAndType(picUri, "image/*"); //set crop properties cropIntent.putExtra("crop", "true"); //indicate aspect of desired crop cropIntent.putExtra("aspectX", 1); cropIntent.putExtra("aspectY", 1); //indicate output X and Y cropIntent.putExtra("outputX", 256); cropIntent.putExtra("outputY", 256); //retrieve data on return cropIntent.putExtra("return-data", true); //start the activity - we handle returning in onActivityResult startActivityForResult(cropIntent, PIC_CROP); }
From source file:com.gdpi.app.UpdateManager.java
/** * APK/* w w w .j a v a2s .c o m*/ */ private void installApk() { /** * android7.0 */ File apkfile = new File(mSavePath, name); if (!apkfile.exists()) { return; } Intent intent = new Intent(Intent.ACTION_VIEW); // Activity?Activity,? intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT >= N) { //?7.0 //?1 , ?2 Provider? ??? ?3 Uri apkUri = FileProvider.getUriForFile(mContext, "com.gpdi.app.fileprovider", apkfile); //??Uri intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); } else { intent.setDataAndType(Uri.fromFile(apkfile), "application/vnd.android.package-archive"); } mContext.startActivity(intent); android.os.Process.killProcess(android.os.Process.myPid()); }
From source file:com.dtworkshop.inappcrossbrowser.WebViewBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @return "" if ok, or error message. *//* ww w .j a v a2 s. c o m*/ public String openExternal(String url) { try { Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. Uri uri = Uri.parse(url); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri)); } else { intent.setData(uri); } this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "InAppBrowser: Error loading url " + url + ":" + e.toString()); return e.toString(); } }