Which permissions do I need to call requestPermission() - Android - android

I'm setting up some permissions in my AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
I request the permission on runtime for all of those permissions.
But somehow the permission REQUEST_INSTALL_PACKAGES does not need to call requestPermission(). If I try to call it anyway, the popup never appears.
Is there a list of permissions i need to call at runtime?
My current android version is 8.0.0.
Thanks

Depends on type of permission you are requesting for. There are two kind of permissions in Android: Normal and Dangerous Permissions
If there are dangerous, you must request for it at runtime for API level 23 and above.
For more info you should read following documentation: https://developer.android.com/guide/topics/permissions/requesting.html#normal-dangerous

Related

Removing duplicate permission from AndroidManifest.xml

The AndroidManifest.xml contains these (and some more) permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
The WRITE_EXTERNAL_STORAGE is contained two times. So I remove one and reorder:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
The audio recorder (https://github.com/3llomi/RecordView) normally requests storage access permission and microphone access permission. But after the change it does not request the storage access anymore and therefore the record view does not work.
I uninstall the app from the device for each manifest change to reset permissions.
How is it possible that removing a duplicate line causes this?
The merged view of the AndroidManifest.xml revealed that another library also declares this permission with maxSdkVersion="18":
The app was running on API>18, I assume therefore it did not request the permission. Removing maxSdkVersion made the storage permission appear again and the recorder view worked:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:remove="android:maxSdkVersion" />
My guess is that because WRITE_EXTERNAL_STORAGE was contained two times in the AndroidManifest.xml, the manifest merging process added the maxSdkVersion only to one of them. The other WRITE_EXTERNAL_STORAGE had no maxSdkVersion hence the app was requesting the permission also on API>18.

Android Media/Photo/Files Permission when Installing the application

I just uploaded my SMS application on Google play store but the problem is that whenever user install the application the app needs access to Photo/Media/Files too. However i donot write this permission in my manifest. please tell me whats the issue
I write following permissions in my app:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
But it still wants to access to media/photo/files
What is the issue?
However i donot write this permission in my manifest.
Yes, you do:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
What is the issue?
You are asking for a permission (WRITE_EXTERNAL_STORAGE) from the STORAGE permission group.

Android M Permissions: Missing some of the old ones

I have to implement the new permissions system but i cant find some of the permissions i used earlier in my android apss:
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
For example: I used:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
I can now replace this by
<uses-permission android:name="android.permission-group.CONTACTS" />
Because GET_ACCOUNTS is in the Group of CONTACTS.
But what about the other permissions i posted. They are not listed anywhere in the system permissions
The following permissions are not present in Android M.
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
Hence, you can request them using android:maxSdkVersion="22" in you uses-permission tag like this:
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" android:maxSdkVersion="22"/>
You can read more about it here.
As for the last permission. That is:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
You don't need to use the permission request for it, as it is allowed.
Looks like some permissions got deprecated in API level 23. If you are targeting API 23, then take care appropriately (i.e. request permission in runtime for "dangerous" permissions).
I think you should still keep them in manifest file for older SDKs.

runtime permissions in Android 6.0

Thanks to this question https://stackoverflow.com/a/32084038/1979882
I found that I have to ask the user if he/she grants my app to retrieve the location. Ok, this work for android.Manifest.permission.ACCESS_FINE_LOCATION in Android 6.0 or it will show this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app/my.pack.mActivity}: java.lang.SecurityException: "network" location provider requires ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission.
But in my application there are several permissions:
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="ru.ps.vm.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
Which of them are needed requestPermissions() method to ask the user?

My App is asking "Microphone: record audio" permission even thought i am not using it

below are permission that i am using
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
there is no microphone permission in my Manifest then why playstore is asking for "MicroPhone" permission while app installation
Although dmitriyzaitsev 's answer is right, I wanted to append it with a method for checking how you can find out which modules add which permissions. To do that, you need to go to the following file:
app/build/outputs/logs/manifest-merger-<app_flavor>-report.txt
There you can search for the permission you are interested in, e.g. RECORD_AUDIO. Your result should look something like this:
ADDED from [com.google.firebase:firebase-common:11.2.2] /Users/jakubkomorowski/.gradle/caches/transforms-1/files-1.1/firebase-common-11.2.2.aar/7f3b39613ed1e03ef066f866e7495b17/AndroidManifest.xml:6:79-143
uses-permission#android.permission.RECORD_AUDIO
You can find out more in the google developer documentation
It seems your app module depends on some other libraries that use this permission.
It's not necessary that microphone audio permission is declared in your AndroidManifest. It can be declared in 3rd-party library.

Categories

Resources