简体   繁体   English

Android中的UIL和android.permission.WRITE_EXTERNAL_STORAGE –棉花糖

[英]UIL and android.permission.WRITE_EXTERNAL_STORAGE in Android – Marshmallow

After adding UIL to my project, I also add permissions: 将UIL添加到我的项目之后,我还添加了权限:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

But for android project with targetSdkVersion="23" (marshmallow) I need to check some "dangerous" permission ( such as WRITE_EXTERNAL_STORAGE ) before use. 但是对于具有targetSdkVersion =“ 23”(棉花糖)的android项目,我需要在使用前检查一些“危险”权限(例如WRITE_EXTERNAL_STORAGE)。

For example: 例如:

if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
                == PackageManager.PERMISSION_GRANTED) {
            Log.v(TAG,"Permission is granted");
            return true;
}

But how can I check it? 但是如何检查呢? I dont know where UIL use it. 我不知道UIL在哪里使用。

Maybe I misunderstanding or miss something from documentation. 也许我误会或错过文档中的某些内容。 Any help would be greatly appreciated. 任何帮助将不胜感激。

But how can I check it? 但是如何检查呢?

Use that code, in your own activity or fragment, to check for the permission, before you try using anything from UIL. 在尝试使用UIL中的任何内容之前,请在您自己的活动或片段中使用该代码检查权限。

Unless the library that you use happens to have activities or fragments, and therefore might be able to requestPermissions() itself, you have to requestPermissions() before using the library, for any dangerous permissions required by that library. 除非您使用该库恰好有活动或片段,并因此可能能够requestPermissions()本身,你必须requestPermissions()使用库,对于任何之前dangerous通过该库所需的权限。

As you note, you have no idea where UIL uses those permissions, and even if you knew for today's UIL, you might not know where UIL uses it tomorrow. 如您所述,您不知道UIL在哪里使用这些权限,即使您知道今天的UIL,明天也可能不知道UIL在哪里使用这些权限。 Hence, you have to check for, and request if needed, the permissions before doing anything with UIL. 因此,您必须在使用UIL进行任何操作之前检查并请求权限(如果需要)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android.permission.WRITE_EXTERNAL_STORAGE权限…是否需要? - android.permission.WRITE_EXTERNAL_STORAGE permission … is it required? 权限 - android.permission.WRITE_EXTERNAL_STORAGE PlayStore - Permission - android.permission.WRITE_EXTERNAL_STORAGE PlayStore 权限拒绝:……需要 android.permission.WRITE_EXTERNAL_STORAGE - Permission Denial: … requires android.permission.WRITE_EXTERNAL_STORAGE Android-从没有android.permission.WRITE_EXTERNAL_STORAGE的资产中播放声音 - Android - Play sound from assets without android.permission.WRITE_EXTERNAL_STORAGE 为什么play-services-location需要android.permission.WRITE_EXTERNAL_STORAGE和android.permission.READ_EXTERNAL_STORAGE权限? - Why does play-services-location need the android.permission.WRITE_EXTERNAL_STORAGE and android.permission.READ_EXTERNAL_STORAGE permissions? 无法插入图片需要android.permission.WRITE_EXTERNAL_STORAGE或grantUriPermission() - Failed to insert image requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission() android棉花糖中的存储权限 - storage permission in android marshmallow 棉花糖中的Android存储权限 - Android storage permission in Marshmallow Android棉花糖requestPermissions WRITE_EXTERNAL_STORAGE - Android Marshmallow requestPermissions WRITE_EXTERNAL_STORAGE Android-允许使用相机并写入外部存储 - Android - Permission to use Camera and Write to External Storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM