5

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

Apostolos
  • 10,033
  • 5
  • 24
  • 39
Jame
  • 3,746
  • 6
  • 52
  • 101
  • Have you targeted api version 23 ? – Ramit Aug 16 '16 at 11:00
  • Yes. First, I tested it in Android 5.0 (21~22) and it has not issue. Now, I want to change the target API version 23 – Jame Aug 16 '16 at 11:01
  • WRITE_EXTERNAL_STORAGE is a dangerous permission. Please check dangerous permission list in https://developer.android.com/guide/topics/security/permissions.html – Ramit Aug 16 '16 at 11:02
  • Hulk added list for you. Please add necessary changes. – Ramit Aug 16 '16 at 11:04

6 Answers6

6

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

Community
  • 1
  • 1
Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81
  • Thank you. So what do I need is that request the permission by programming. It will ask the user and then automatically add for my app. Is it right? Does it ask second times when app is ran again? – Jame Aug 16 '16 at 11:05
  • Hello user8430, this question is regarding list, so first approve you answer and open another question for how to ask permission, i will help you there, best luck bro :) – Yogesh Rathi Aug 16 '16 at 11:07
  • I upvote your answer. I do not know who downvotes it – Jame Aug 16 '16 at 11:08
5
<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

earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
Abhishek
  • 1,654
  • 2
  • 18
  • 31
1
<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.

earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
  • So, instead of add two above permissions in `AndroidManifest.xml` file. I must use requestPermission() function to add these permissions onCreate() function. Is it right? – Jame Aug 16 '16 at 11:11
  • 1
    You need to have them in the Manifest also, for devices with lower API levels. It's not mandatory to request them in `onCreate()`, just request them before calling any function that would need them. – earthw0rmjim Aug 16 '16 at 11:12
1

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

earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
Sagar Gangawane
  • 1,985
  • 1
  • 12
  • 22
1

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+

earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
Fer
  • 1,956
  • 2
  • 28
  • 35
1

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

Marco C.
  • 1,282
  • 2
  • 15
  • 19