问题
Since API level 23, android introduced a new approach to grant 'dangerous' permissions , while the app is running. That means that permissions such as camera access, phone call access and such will have to be given during run time.
I can completely understand why this can often be very useful, and less intimidating to users in the installation process. However, an app which uses many such 'dangerous' permissions (for all the right reasons) can easily annoy a user with so many requests in runtime. Is there still a way to force the user to grant 'dangerous' permissions during installation?
回答1:
Is there still a way to force the user to grant 'dangerous' permissions during installation?
No, unless you set your targetSdkVersion
to 22 or lower, so the permissions are granted at install time due to backward compatibility.
If you have an app that requires too many permissions (i.e. permission-groups) at once (e.g. at first startup), you may consider to redesign your app to only request the permissions when they are really required.
回答2:
As Foern has answered the only way to force users to accept permissions at installation and not runtime is to user an sdk less than 23. This will become difficult to maintain an app over time as api are updated further and the app gradually has deprecated methods.
The difference in what you perceive as "annoyance" to the user is not so great.
The user can save the runtime permissions as default, so the permissions are not required everytime the app is run. This permission can also be revoked at any time by the user. However, there is little difference between accepting the permissions and making them default answers once at runtime than accepting them at installation.
For developers there is some more work to do with runtime permissions, but for users there is supposed to be an added level of protection and autonomy by not having to accept all permissions at installation.
As from the link:
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app. It also gives the user more control over the app's functionality; for example, a user could choose to give a camera app access to the camera but not to the device location. The user can revoke the permissions at any time, by going to the app's Settings screen.
来源:https://stackoverflow.com/questions/34514264/require-dangerous-permissions-during-installation