List of usage examples for android.content Intent FLAG_GRANT_READ_URI_PERMISSION
int FLAG_GRANT_READ_URI_PERMISSION
To view the source code for android.content Intent FLAG_GRANT_READ_URI_PERMISSION.
Click Source Link
From source file:com.dm.material.dashboard.candybar.adapters.IntentAdapter.java
private Intent addIntentExtra(@NonNull Intent intent) { intent.setType("message/rfc822"); if (mRequest.getStream().length() > 0) { File zip = new File(mRequest.getStream()); Uri uri = FileHelper.getUriFromFile(mContext, mContext.getPackageName(), zip); if (uri == null) uri = Uri.fromFile(zip);/* w w w.j a va 2 s . c o m*/ intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } intent.putExtra(Intent.EXTRA_EMAIL, new String[] { mContext.getResources().getString(R.string.dev_email) }); intent.putExtra(Intent.EXTRA_SUBJECT, mRequest.getSubject()); intent.putExtra(Intent.EXTRA_TEXT, mRequest.getText()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); return intent; }
From source file:com.theaetetuslabs.android_apkmaker.InstallActivity.java
private Intent getInstallIntent() { Intent promptInstall = new Intent(Intent.ACTION_INSTALL_PACKAGE); promptInstall.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); promptInstall.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); promptInstall.putExtra(Intent.EXTRA_RETURN_RESULT, true); return promptInstall; }
From source file:com.Jsu.framework.image.imageChooser.ImageChooserManager.java
private void choosePicture() throws ChooserException { checkDirectory();/*www. j a v a2s . c om*/ try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); // intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); if (extras != null) { intent.putExtras(extras); } intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); } catch (ActivityNotFoundException e) { throw new ChooserException(e); } }
From source file:com.example.linhdq.test.documents.creation.NewDocumentActivity.java
protected void startGallery() { cameraPicUri = null;/* w w w . j av a 2s .co m*/ Intent i; if (Build.VERSION.SDK_INT >= 19) { i = new Intent(Intent.ACTION_GET_CONTENT, null); i.addCategory(Intent.CATEGORY_OPENABLE); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.setType("image/*"); i.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/png", "image/jpg", "image/jpeg" }); } else { i = new Intent(Intent.ACTION_GET_CONTENT, null); i.setType("image/png,image/jpg, image/jpeg"); } Intent chooser = Intent.createChooser(i, this.getResources().getString(R.string.image_source)); try { startActivityForResult(chooser, REQUEST_CODE_PICK_PHOTO); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.no_gallery_found, Toast.LENGTH_LONG).show(); } }
From source file:com.king.base.util.SystemUtils.java
/** * apk/*from w w w .j a v a 2s . co m*/ * @param context * @param file */ public static void installApk(Context context, File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uriData = null; String type = "application/vnd.android.package-archive"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); uriData = FileProvider.getUriForFile(context, context.getPackageName() + ".fileProvider", file); } else { uriData = Uri.fromFile(file); } intent.setDataAndType(uriData, type); context.startActivity(intent); }
From source file:org.wahtod.wififixer.utility.LogUtil.java
public static void sendIssueReport(Activity activity, String report, File file) { Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(activity.getString(R.string.log_mimetype)); sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getString(R.string.email) }); sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.subject)); Uri uri = FileProvider.getUriForFile(activity, "org.wahtod.wififixer.files", file); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); List<ResolveInfo> resInfoList = activity.getPackageManager().queryIntentActivities(sendIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); }//from ww w . j a va 2 s . c o m sendIntent.putExtra(Intent.EXTRA_TEXT, LogUtil.getBuildInfo() + "\n\n" + report); activity.startActivityForResult(Intent.createChooser(sendIntent, activity.getString(R.string.emailintent)), 1); }
From source file:com.android.cts.intent.sender.IntentSenderTest.java
private void grantPersistableReadPermission(Uri uri) throws Exception { Intent grantPersistable = new Intent(ACTION_TAKE_PERSISTABLE_URI_PERMISSION); grantPersistable.setClipData(ClipData.newRawUri("", uri)); grantPersistable// ww w . ja v a2 s. c o m .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); mActivity.getResult(grantPersistable); }
From source file:org.chaos.fx.cnbeta.details.ImageFragment.java
private void shareToMore() { final String path = getImageCachePath(); storeImageToLocalIfNeed(path, new Callback() { @Override/*from w ww. ja v a 2 s . c om*/ public void onSuccess() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/jpg"); if (Build.VERSION.SDK_INT >= 24) { shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getActivity().getApplicationContext(), BuildConfig.APPLICATION_ID + ".provider", new File(path))); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); } startActivity(Intent.createChooser(shareIntent, getString(R.string.share_to))); } @Override public void onError(Exception e) { failedToStoreImage(e); } }); }
From source file:com.jefftharris.passwdsafe.StorageFileListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_file_open: { startOpenFile();/*from w w w .j a v a2 s.c om*/ return true; } case R.id.menu_file_new: { startActivity(new Intent(PasswdSafeUtil.NEW_INTENT)); return true; } case R.id.menu_clear_recent: { try { ContentResolver cr = getActivity().getContentResolver(); int flags = Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION; Cursor cursor = itsRecentFilesDb.queryFiles(); if (cursor != null) { try { while (cursor.moveToNext()) { Uri uri = Uri.parse(cursor.getString(RecentFilesDb.QUERY_COL_URI)); ApiCompat.releasePersistableUriPermission(cr, uri, flags); } } finally { cursor.close(); } } itsRecentFilesDb.clear(); List<Uri> permUris = ApiCompat.getPersistedUriPermissions(cr); for (Uri permUri : permUris) { ApiCompat.releasePersistableUriPermission(cr, permUri, flags); } getLoaderManager().restartLoader(LOADER_FILES, null, this); } catch (Exception e) { PasswdSafeUtil.showFatalMsg(e, "Clear recent error", getActivity()); } return true; } default: { return super.onOptionsItemSelected(item); } } }
From source file:com.android.cts.intent.sender.ContentTest.java
private void grantPersistableReadPermission(Uri uri) throws Exception { Intent grantPersistable = new Intent(ACTION_TAKE_PERSISTABLE_URI_PERMISSION); grantPersistable.setClipData(ClipData.newRawUri("", uri)); grantPersistable//w ww . j a v a2 s.c om .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); mActivity.getCrossProfileResult(grantPersistable); }