No permission to write on android emulator - android

I have been trying to download a file from a url.
I have set the permissions in my android manifest file like so,
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I am using a library called Adavnced WebView to handle downloads:
AdvancedWebView.handleDownload(view.getContext(),"https://static1.squarespace.com/static/57752cbed1758e541bdeef6b/t/58d91311ff7c50b172946ee5/1490621221735/PreKGuide_2017_English_032417+%281%29.pdf" , "abc.txt");
I get an error when I try to download. It clearly says that the app doesn't have permission to write to storage path. How can I set permission to write? What am I missing here? Please help.
java.lang.SecurityException: No permission to write to /storage/emulated/0/Download/abc.txt: Neither user 10147 nor current process has android.permission.WRITE_EXTERNAL_STORAGE.

You need the runtime permission, check the documentation.

Related

Android permission not asked correctly with version 31

I have a Android app done with Delphi 10.4 (upgraded to 11.2).
I have lot of permission in my AndroidManifest.xml :
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="29"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_CALENDAR"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="oppo.permission.OPPO_COMPONENT_SAFE"/>
<uses-permission android:name="com.huawei.permission.external_app_settings.USE_COMPONENT"/>
Then I ask for runtime permissions :
PermissionsService.RequestPermissions(
[JStringToString(TJManifest_permission.JavaClass.CAMERA),
JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE),
JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE),
JStringToString(TJManifest_permission.JavaClass.READ_PHONE_STATE),
JStringToString(TJManifest_permission.JavaClass.RECORD_AUDIO)
], ...
That's work perfectly, but when I want to publish my app, Play store ask to update my Sdk version to 31 (I replace 29 by targetSdkVersion="31")
I add exported=true when necessary and replace :
<uses-permission android:name="android.permission.BLUETOOTH"/>
// by
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
// and added BLUETOOTH_SCAN + BLUETOOTH_ADVERTISE + BLUETOOTH_CONNECT
On Android 13, permission are not asked correctly.
The first time I open the app, the application ask me to accept BLUETOOTH only and then nothing append, but the app still working and crash when I want use the Camera.
If I close the app and open it, then my application ask me for the others permissions (Camera, Read/Write, ..)
I try to put Bluetooth at the end of the file, but I got same problem.
If I use targetSdkVersion="29" as before, it's ok.
Based on the documentation I dont see what to do : https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android12-or-higher
Thanks
I faced a similar issue. I had to move the code of asking for the permissions to different places. So when the application starts, I ask for Bluetooth permissions only. Before using the storage, I added to code to ask for the storage permission. Before using the camera, I did the same.

READ_PHONE_STATE permission seems to be actively rejected in Android 11

I have an application with following permissions in Manifest:
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I manually enabled all permissions through Settings in an Android 11 mobile. However, if I use ActivityCompat.checkSelfPermission(this,(Manifest.permission.READ_PHONE_STATE)) to check if READ_PHONE_STATE permission has been granted, the result is always PERMISSION_DENIED.
I then used ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_PHONE_STATE), 102), which simply calls onRequestPermissionsResult with grant result PERMISSION_DENIED immediately.
I reproduced this on two Android 11 devices (one physical, one emulator), and I tried changing the package name, uninstalling and reinstalling the app etc.
I figured out what went wrong. One of the libraries I was including had this:
Library's Manifest
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
android:maxSdkVersion="29" />
and even though I defined this permission in my app manifest, the maxSdkVersion got into my app.
The solution is to remove the maxSdkVersion property in your app:
App's Manifest
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
tools:remove="android:maxSdkVersion" />

Which permissions do I need to call requestPermission() - 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

Android: Why is android.permission.ACCESS_WIFI_STATE automatically added to my signed apk build?

My app uses a couple of permission:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
and:
android:permission="com.google.android.c2dm.permission.SEND">
Yesterday I uploaded a new version to google play and somehow the
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
has been added and thus users won't get an auto update of my app but have to give permission first. I don't want this permission added to my project, but I have no idea how to remove it since pre-build it's not requested in my code anywhere.
Does anyone have some advice?
I was able to remove the permission by adding:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
tools:node="remove"/>
Also #Arnav: I wasn't using any functionality of the library that needed this permission so removing caused no issues.
The library projects as dependency needs to be used as this require that permission. You have enabled the manifestmerger property true in project properties () because of which this issue may occurs.
This permission can be removed as follow:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
tools:node="remove"/>

Why my app requesting media permission when installing?

I released my application in Google Play and when trying to install it it requesting access to Media although I didn't set that in the Manifest file
Here are my permissions in the Manifest file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
when in installing my app from the phone it asks from media access:
but when I open my app in the desktop browser it doesn’t show Media permission with the other permissions:
There was android.permission.WRITE_EXTERNAL_STORAGE permission in my app but i removed it and updated my app yesterday but Google Play still requesting Media access when trying to install it so i cleared Google Play's cache and tried again and now it doesn't request that permission any more . Thank you

Categories

Resources