本文整理了Java中android.app.Activity.grantUriPermission()
方法的一些代码示例,展示了Activity.grantUriPermission()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.grantUriPermission()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:grantUriPermission
暂无
代码示例来源:origin: jeasonlzy/ImagePicker
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param toPackage
* @param uri
* @param modeFlags
* @see android.content.ContextWrapper#grantUriPermission(java.lang.String,
* android.net.Uri, int)
*/
public void grantUriPermission(String toPackage,
Uri uri,
int modeFlags) {
mActivity.grantUriPermission(toPackage, uri, modeFlags);
}
代码示例来源:origin: limboemu/limbo
public static String getFileUriFromIntent(Activity activity, Intent data, boolean write) {
if(data == null)
return null;
Uri uri = data.getData();
DocumentFile pickedFile = DocumentFile.fromSingleUri(activity, uri);
String file = uri.toString();
if (!file.contains("com.android.externalstorage.documents")) {
UIUtils.showFileNotSupported(activity);
return null;
}
activity.grantUriPermission(activity.getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
if(write)
activity.grantUriPermission(activity.getPackageName(), uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
activity.grantUriPermission(activity.getPackageName(), uri, Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
int takeFlags = data.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION;
if(write)
takeFlags = takeFlags | Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
activity.getContentResolver().takePersistableUriPermission(uri, takeFlags);
return file;
}
代码示例来源:origin: JakePrim/PrimFilePicker
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
mContext.get().grantUriPermission(packageName, cameraUri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: windrunnerlihuan/DogCamera
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
activity.grantUriPermission(packageName, shareFileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: JakePrim/PrimFilePicker
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
mContext.get().grantUriPermission(packageName, cameraUri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: AppLozic/Applozic-Android-SDK
activity.grantUriPermission(packageName, capturedImageUri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
activity.grantUriPermission(packageName, capturedImageUri,
Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: jkennethcarino/DroidOVPN
String packageName = resolvedIntentInfo.activityInfo.packageName;
activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: AppLozic/Applozic-Android-SDK
activity.grantUriPermission(packageName, videoFileUri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
activity.grantUriPermission(packageName, videoFileUri,
Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: antest1/kcanotify
} else {
Uri ringtoneUri = Uri.parse(uri);
getActivity().grantUriPermission(BuildConfig.APPLICATION_ID, ringtoneUri, FLAG_GRANT_READ_URI_PERMISSION);
Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
if (ringtone == null) {
代码示例来源:origin: antest1/kcanotify
} else {
Uri ringtoneUri = Uri.parse(uri);
getActivity().grantUriPermission(BuildConfig.APPLICATION_ID, ringtoneUri, FLAG_GRANT_READ_URI_PERMISSION);
Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri);
if (ringtone == null) {
内容来源于网络,如有侵权,请联系作者删除!