问题
I have an android code which can work well on Android 5.0 version. My AndroidManifest.xml
is
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
However, my customer who uses Android 6.0 (LG G5) reported the application does not work well. I do not have LG G5 to check what is the issue. In my opinion, I think the reason is that the permission changed from 5.0 to 6.0. Could you look at my permission and give me some improve/correct it for Android 6.0? Or do we have any way to automatically add permission for Android 6.0. Thank all
回答1:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
These permissions will be run time permissions inn your App
For more info:
https://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en
Check out this will help you
回答2:
In Android 6.0, this includes:
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
ADD_VOICEMAIL
BODY_SENSORS
CALL_PHONE
CAMERA
GET_ACCOUNTS
PROCESS_OUTGOING_CALLS
READ_CALENDAR
READ_CALL_LOG
READ_CELL_BROADCASTS
READ_CONTACTS
READ_EXTERNAL_STORAGE
READ_PHONE_STATE
READ_SMS
RECEIVE_MMS
RECEIVE_SMS
RECEIVE_WAP_PUSH
RECORD_AUDIO
SEND_SMS
USE_SIP
WRITE_CALENDAR
WRITE_CALL_LOG
WRITE_CONTACTS
WRITE_EXTERNAL_STORAGE
For these permissions, not only does your targetSdkVersion 23+ app need to have the element(s), but you also have to ask for those permissions at runtime from the user on Android 6.0+ devices, using methods like checkSelfPermission() and requestPermissions().
How to ask permission link
回答3:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
These are dangerous permissions, you need to request them at runtime on API level 23+.
A complete list of dangerous permissions can be found here.
Check out the developers guide on Requesting Permissions at Run Time.
回答4:
In your application have to take the permissions at run time not at the app installation time.
android.permission.WRITE_EXTERNAL_STORAGE
is a dangerous permission as per the documentation you can check this Dyanamic permission in 6.0
回答5:
In Android Marshmallow the managing of permissions is totally different to previous versions. If you target API 23 you will have to request the user to allow this or that permission from the app.
Take a look to: Android permissions
I think (not tested) that if you set API 22 or less you won't have the problem with permissions although the app is installed in a device with Android 6.0+
回答6:
Android 6 has improved the way android handles app permissions, if your app requires a dangerous permission (complete list here https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous) you need to check that permission runtime, therefore defining permission in your manifest is not enough. The reason of this new permission management is related to the fact that android users can enable/disable app permissions runtime, so your code needs to be aware that specific features (camera, gps etc) are not granted by default and might change over time.
There are many libraries that help you manage app permissions, I think the most used is Permissions Dispatcher: https://github.com/hotchemi/PermissionsDispatcher
Also take a look at the official documentation here: https://developer.android.com/training/permissions/requesting.html
来源:https://stackoverflow.com/questions/38973118/which-permission-do-we-need-at-runtime-in-android-6-0