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.android.mms.ui.MessageUtils.java
public static void viewSimpleSlideshow(Context context, SlideshowModel slideshow) { if (!slideshow.isSimple()) { throw new IllegalArgumentException("viewSimpleSlideshow() called on a non-simple slideshow"); }/*from w w w .j av a 2 s . co m*/ SlideModel slide = slideshow.get(0); MediaModel mm = null; if (slide.hasImage()) { mm = slide.getImage(); } else if (slide.hasVideo()) { mm = slide.getVideo(); } else if (slide.hasAudio()) { mm = slide.getAudio(); } Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra("SingleItemOnly", true); // So we don't see "surrounding" images in Gallery /// M: CanShare: false, Hide the videopalye's share option menu. /// M: CanShare: ture, Show the share option menu. /// M: Code analyze 010, For fix bug ALPS00244046, The "JE" pops up // after you tap the "messaging" icon. @{ intent.putExtra("CanShare", false); /// @} /// M: for showing notification when view mms with video player in full screen model @{ intent.putExtra(EXTRA_FULLSCREEN_NOTIFICATION, true); /// @} String contentType = ""; if (mm != null) { contentType = mm.getContentType(); MmsLog.e(TAG, "viewSimpleSildeshow. Uri:" + mm.getUri()); MmsLog.e(TAG, "viewSimpleSildeshow. contentType:" + contentType); intent.setDataAndType(getPreviewFileUri(context, mm), contentType); } /// M: Code analyze 013, For fix bug ALPS00250939, Exception/Java(JE)-->com.android.mms. try { // M: change feature ALPS01751464 if (mm != null && mm.hasDrmContent()) { DrmUtilsEx.showDrmAlertDialog(context); return; } context.startActivity(intent); } catch (ActivityNotFoundException e) { Message msg = Message.obtain(MmsApp.getToastHandler()); msg.what = MmsApp.MSG_MMS_CAN_NOT_OPEN; msg.obj = contentType; msg.sendToTarget(); /// M: after user click view, and the error toast is shown, /// we must make it can press again. tricky code if (context instanceof ComposeMessageActivity) { ((ComposeMessageActivity) context).mClickCanResponse = true; } } /// @} }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
private Intent getDefaultShareIntent() { Intent intent = new Intent(Intent.ACTION_SEND); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType(SharedImageProvider.MIME_TYPE); mSharedOutputFile = SaveImage.getNewFile(this, MasterImage.getImage().getUri()); Uri uri = Uri.withAppendedPath(SharedImageProvider.CONTENT_URI, Uri.encode(mSharedOutputFile.getAbsolutePath())); intent.putExtra(Intent.EXTRA_STREAM, uri); return intent; }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) private boolean openDocument() { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); final String[] mimeTypes = { "image/png", "image/jpeg", "image/gif" }; intent.setType("image/*"); intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try {/*from www . j a v a2 s . c om*/ startActivityForResult(intent, REQUEST_OPEN_DOCUMENT); } catch (final ActivityNotFoundException e) { return false; } return true; }
From source file:org.kontalk.ui.AbstractComposeFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private Intent createGalleryIntent(boolean useSAF) { Intent intent;/* w ww. ja v a 2 s . c o m*/ if (!useSAF) { intent = SystemUtils.externalIntent(Intent.ACTION_GET_CONTENT) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { intent = SystemUtils.externalIntent(Intent.ACTION_OPEN_DOCUMENT); } return intent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*") .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }
From source file:me.tb.player.SkeletonActivity.java
public static void createInstagramIntent(Context context, String type, String mediaPath, String caption) { // Create the new Intent using the 'Send' action. Intent share = new Intent(Intent.ACTION_SEND); // Set the MIME type share.setType(type);//ww w. j av a2 s. c o m // Create the URI from the media File media = new File(mediaPath); Uri uri = Uri.fromFile(media); // Add the URI and the caption to the Intent. share.putExtra(Intent.EXTRA_STREAM, uri); share.putExtra(Intent.EXTRA_TEXT, caption); share.putExtra(Intent.EXTRA_SUBJECT, "Check this out"); share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Broadcast the Intent. context.startActivity(Intent.createChooser(share, "Share to")); }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
private void onFinished(Uri... uris) { Log.d(TAG, "onFinished() " + Arrays.toString(uris)); final Intent intent = new Intent(); if (uris.length == 1) { intent.setData(uris[0]);//from www. j a va2 s.co m } else if (uris.length > 1) { final ClipData clipData = new ClipData(null, mState.acceptMimes, new ClipData.Item(uris[0])); for (int i = 1; i < uris.length; i++) { clipData.addItem(new ClipData.Item(uris[i])); } intent.setClipData(clipData); } if (mState.action == ACTION_GET_CONTENT) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); } setResult(Activity.RESULT_OK, intent); finish(); }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
private void pickImage() { final Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try {/* w w w.j a va 2s .com*/ startActivityForResult(intent, REQUEST_PICK_IMAGE); } catch (final ActivityNotFoundException e) { showErrorMessage(this, null, e, false); } }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
private void fireIntent(Slide slide) { if (slide != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(PartAuthority.getPublicPartUri(slide.getUri()), slide.getContentType()); try {//ww w . jav a 2 s. c o m getActivity().startActivity(intent); } catch (ActivityNotFoundException anfe) { Log.w("GDATA", anfe.getMessage() + " - " + slide.getContentType()); } } }
From source file:com.android.gallery3d.app.PhotoPage.java
private static Intent createShareIntent(MediaObject mediaObject) { int type = mediaObject.getMediaType(); return new Intent(Intent.ACTION_SEND).setType(MenuExecutor.getMimeType(type)) .putExtra(Intent.EXTRA_STREAM, mediaObject.getContentUri()) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); }
From source file:com.intuit.qboecoui.email.SalesFormEmail.java
/** * invoke the pdf viewer to show the downloaded PDF. *//*from ww w .j a v a 2s. c o m*/ private void startExternalPreviewActivity() { if (hasPreviewLaunched) { return; } hasPreviewLaunched = true; // track the launch of external pdf viewer //SalesFormEmail.SFM_Flow_tracking = Util.buildTrackingFlow(SalesFormEmail.SFM_Flow_tracking, QBMTrackConstants.SFM_OPEN_PDF ); BaseApplicationModule.getTrackingModule().trackLink(QBMTrackConstants.SALES_FORM_EMAIL_PAGE_NAME, QBMTrackConstants.SFM_OPEN_PDF); try { mPDFFileName = AppPreferences.getStringPreference(this.getApplicationContext(), BaseAppPreferences.PREFS_QBSHAREDLIB, QBODocumentLinkEntity.KEY_PDF_FILENAME, null); File file = new File(mPDFFileName); Uri fileUri = FileProvider.getUriForFile(this, this.getApplicationContext().getResources().getString(R.string.file_provider_authorities), file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(fileUri, this.getContentResolver().getType(fileUri)); startActivity(intent); } catch (final ActivityNotFoundException e) { displayError(R.string.error_pdf_viewer_not_present, R.string.error_title_error, false); } }