[英]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.