在 Android 中我应该在运行时询问哪些权限,哪些我不必在运行时询问?
Which permissions should I ask at runtime and which I don't have to ask runtime in Android?
我如何确定我应该在运行时请求哪些权限以及'enough' 哪些权限已在清单中声明?
危险权限应该在运行时询问,清单中足够正常。您可以看到的危险和正常权限列表 here。
来自docs:
System permissions are divided into several protection levels. The two
most important protection levels to know about are normal and
dangerous permissions:
Normal permissions cover areas where your app needs to access data or
resources outside the app's sandbox, but where there's very little
risk to the user's privacy or the operation of other apps. For
example, permission to set the time zone is a normal permission. If an
app declares that it needs a normal permission, the system
automatically grants the permission to the app. For a full listing of
the current normal permissions, see Normal permissions.
Dangerous
permissions cover areas where the app wants data or resources that
involve the user's private information, or could potentially affect
the user's stored data or the operation of other apps. For example,
the ability to read the user's contacts is a dangerous permission. If
an app declares that it needs a dangerous permission, the user has to
explicitly grant the permission to the app. Special Permissions There
are a couple of permissions that don't behave like normal and
dangerous permissions. SYSTEM_ALERT_WINDOW and WRITE_SETTINGS are
particularly sensitive, so most apps should not use them. If an app
needs one of these permissions, it must declare the permission in the
manifest, and send an intent requesting the user's authorization. The
system responds to the intent by showing a detailed management screen
to the user.
For details on how to request these permissions, see the
SYSTEM_ALERT_WINDOW and WRITE_SETTINGS reference entries.
如果您的目标是 Android Marshmallow 及更高版本,则必须在运行时请求危险权限。您可以找到列表 here. You should also read this.
您应该始终将您想要访问的所有权限放在清单中。 Android Marshmallow 之前的设备无法处理运行时权限,因此除非您只针对 Marshmallow 及更高版本,否则这部分很重要。
您不需要在运行时询问任何“Normal Permissions”。只有指定为 "dangerous" 的权限不会自动授予。
System permissions are divided into two categories, normal and dangerous:
Normal permissions do not directly risk the user's privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically.
Dangerous permissions can give the app access to the user's confidential data. If your app lists a normal permission in its manifest, the system grants the permission automatically. If you list a dangerous permission, the user has to explicitly give approval to your app.
有关详细信息,请参阅 normal permissions and dangerous permissions 上的文档。
我如何确定我应该在运行时请求哪些权限以及'enough' 哪些权限已在清单中声明?
危险权限应该在运行时询问,清单中足够正常。您可以看到的危险和正常权限列表 here。
来自docs:
System permissions are divided into several protection levels. The two most important protection levels to know about are normal and dangerous permissions:
Normal permissions cover areas where your app needs to access data or resources outside the app's sandbox, but where there's very little risk to the user's privacy or the operation of other apps. For example, permission to set the time zone is a normal permission. If an app declares that it needs a normal permission, the system automatically grants the permission to the app. For a full listing of the current normal permissions, see Normal permissions.
Dangerous permissions cover areas where the app wants data or resources that involve the user's private information, or could potentially affect the user's stored data or the operation of other apps. For example, the ability to read the user's contacts is a dangerous permission. If an app declares that it needs a dangerous permission, the user has to explicitly grant the permission to the app. Special Permissions There are a couple of permissions that don't behave like normal and dangerous permissions. SYSTEM_ALERT_WINDOW and WRITE_SETTINGS are particularly sensitive, so most apps should not use them. If an app needs one of these permissions, it must declare the permission in the manifest, and send an intent requesting the user's authorization. The system responds to the intent by showing a detailed management screen to the user.
For details on how to request these permissions, see the SYSTEM_ALERT_WINDOW and WRITE_SETTINGS reference entries.
如果您的目标是 Android Marshmallow 及更高版本,则必须在运行时请求危险权限。您可以找到列表 here. You should also read this.
您应该始终将您想要访问的所有权限放在清单中。 Android Marshmallow 之前的设备无法处理运行时权限,因此除非您只针对 Marshmallow 及更高版本,否则这部分很重要。
您不需要在运行时询问任何“Normal Permissions”。只有指定为 "dangerous" 的权限不会自动授予。
System permissions are divided into two categories, normal and dangerous:
Normal permissions do not directly risk the user's privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically.
Dangerous permissions can give the app access to the user's confidential data. If your app lists a normal permission in its manifest, the system grants the permission automatically. If you list a dangerous permission, the user has to explicitly give approval to your app.
有关详细信息,请参阅 normal permissions and dangerous permissions 上的文档。