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:Main.java
private static void addPhotoPickerExtras(Intent intent, Uri photoUri) { intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, photoUri)); }
From source file:Main.java
/** * Get the intent used to open installation U.I. * * @param fileUri downloaded file URI from the download manager. * @return intent to open installation U.I. *///from w w w. j a v a2 s . com @NonNull static Intent getInstallIntent(Uri fileUri) { Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setData(fileUri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); return intent; }
From source file:Main.java
public static Intent getOpenFileIntent(Uri uri, String mimeType) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(uri, mimeType); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); return intent; }
From source file:com.duy.ascii.sharedcode.ShareUtil.java
public static void shareImage(Context context, File file) { Uri uri;//from w ww.ja va 2s . c o m if (Build.VERSION.SDK_INT >= 24) { uri = FileProvider.getUriForFile(context, context.getPackageName() + ".provider", file); } else { uri = Uri.fromFile(file); } Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType("image/*"); context.startActivity(Intent.createChooser(intent, "Share image via")); }
From source file:Main.java
public static void share(Context pContext, String urlToShare, String titleChosser, String subject) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, urlToShare); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); pContext.startActivity(Intent.createChooser(intent, titleChosser)); }
From source file:com.commonsware.android.tte.DocumentStorageService.java
public static void loadDocument(Context ctxt, Uri document) { Intent i = new Intent(ctxt, DocumentStorageService.class).setAction(Intent.ACTION_OPEN_DOCUMENT) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION).setData(document); ctxt.startService(i);/* w w w. j av a 2 s. c om*/ }
From source file:com.commonsware.android.tte.DocumentStorageService.java
public static void saveDocument(Context ctxt, Uri document, String text, boolean isClosing) { Intent i = new Intent(ctxt, DocumentStorageService.class).setAction(Intent.ACTION_EDIT).setData(document) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION) .putExtra(Intent.EXTRA_TEXT, text).putExtra(EXTRA_CLOSING, isClosing); ctxt.startService(i);// ww w . j a va 2s . c o m }
From source file:org.andstatus.app.util.UriUtils.java
/** See http://developer.android.com/guide/topics/providers/document-provider.html */ @TargetApi(Build.VERSION_CODES.KITKAT)//w w w.ja va 2 s . co m public static int flagsToTakePersistableUriPermission() { int flags = Intent.FLAG_GRANT_READ_URI_PERMISSION; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { flags = flags | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; } return flags; }
From source file:com.example.linhdq.test.main_menu.ContactActivity.java
public static Intent getFeedbackIntent(Context context, String subject, File file, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); if (subject != null) { intent.putExtra(Intent.EXTRA_SUBJECT, subject); }/*from w w w .ja v a 2 s .c o m*/ if (file.exists()) { final Uri uriForFile = FileProvider.getUriForFile(context, context.getString(R.string.config_share_file_auth), file); intent.putExtra(Intent.EXTRA_STREAM, uriForFile); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } if (body != null) { intent.putExtra(Intent.EXTRA_TEXT, body); } intent.putExtra(Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL }); return intent; }
From source file:com.renard.ocr.main_menu.ContactActivity.java
public static Intent getFeedbackIntent(Context context, String subject, File file, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); if (subject != null) { intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); }/*ww w . j a va 2s.c om*/ if (file.exists()) { final Uri uriForFile = FileProvider.getUriForFile(context, context.getString(R.string.config_share_file_auth), file); intent.putExtra(Intent.EXTRA_STREAM, uriForFile); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } if (body != null) { intent.putExtra(Intent.EXTRA_TEXT, body); } intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL }); return intent; }