I'm debugging my Android device and trying to pick an image with image_picker through ImageSource.gallery.
The device is asking permission for ALL storage (I'm using permission_handler).
The problem is when I try to check permission status for manageExternalStorage which comes up always as Restricted.
Is there a way to check permission for Storage?
I was able to make it work by changing the permission from manageExternalStorage which is restricted to storage.
Related
How can I request permission MANAGE_EXTERNAL_STORAGE on android 11 (wear os)
I try this code:
[enter image description here](https://i.stack.imgur.com/AV1Zg.png)
But it alway allow only while using app. Is anyone try it ? How can I grant allow all the time permission.
In my app, i am fetching WhatsApp status from /storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/.Statuses/ folder everything working fine till Android 10, but in android 11 it shows nothing. Please guild me for this.
app showing status till 29 when change tp 30 folder show nothing.
The Status directory has changed to /Android/media/com.whatsapp/.Statuses due to the new changes of Android 11 which do not give access to External Storage as freely as before Android versions
You can read about the changes here in
detail
To summarise the exact cause of this change, is the WhatsApp was previously using the External Storage by creating it's own folder and that is not possible with the new scoped storage without requesting the MANAGE_EXTERNAL_STORAGE permission. Google will usually reject your app on the playstore if you request this permission. So WhatsApp has moved all of its required stuff in the above directory since the Android/data/ directory is no longer accessible and they want the user to access all of this data
There is an Android App which accesses the WhatsApp status directory and you can find it here
Let the user pick the directory with ACTION_OPEN_DOCUMENT_TREE.
I'm trying to achieve some clean up tools. More and more manufacturers have forbidden rooting devices due to some "security reason", it's forbidden NOT to request for unlock.
After API 28, This code will make error:
ActivityCompat.requestPermissions(this, new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
}, 1); // Request permission or not, Will got same result
File rootFolder = Environment.getExternalStorageDirectory(); // That is working fine
rootFolder.listFiles(); // That will return null
Sure, I can use this:
android:requestLegacyExternalStorage="true"
But I belive that will be killed in future.
So, Any elegant way to manage SDCard?
On Android 10 Environment.getExternalStorageDirectory() and Environment.getExternalStoragePublicDirectory() will return storage paths but paths are not readable or writable.
For Android 10 you can continue to use paths provided by Environment.getExternalStorageDirectory() and Environment.getExternalStoragePublicDirectory() if you add android:requestLegacyExternalStorage="true" to application tag in manifest file. At runtime your app can call Environment.isExternalStorageLegacy() to check if the request has been done.
Another (not known) possibility (only for Android 10) is to add <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> to manifest file.
The user has to go to the advanced settings of the app and enable from Advanced settings Install unknown apps | Allow from this source.
The nice thing with this is that the user can switch the access rights. You can make it easier for the user if you implement an intent for
Settings.ACTION_APPLICATION_DETAILS_SETTINGS where he can change the settings.
A funny thing is that Environment.isExternalStorageLegacy() returns true then too.
Compiling for Android 11 both options do not work on an Android 11 device. (But they continue to work for Android 10 devices). The paths of Environment.getExternalStorageDirectory() and Environment.getExternalStoragePublicDirectory() are usable again in read mode and very often in write mode too. And this is great as one can simply list the contents of directories like Download or Pictures or DCIM/Camera again using the File class.
But adding <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> to manifest file and implementing an intent for
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION will give your app read/write access for all files even on removable micro sd card.
(Finally you can remove the google ban not being able to read/write your own micro sd card on your own Android device using your own app).
Environment.isExternalStorageManager() can be used to check if the permission is on/off.
As long as you do not try to upload your app to the play store you are fine.
use android:requestLegacyExternalStorage="true" in your Manifest below <application
Hi dear android developers!
When my installed on any android device it asked the following permission from the user.
I did not want anything from the user in my app, so I want to remove this permission from my app but I did not figure out the name of this permission in my android manifest.xml file. Please tells the name of this permission So I can remove it from my android manifest.xml file.
Thanks in advance...
READ_EXTERNAL_STORAGE is the permission. Butin general you should not request any permission you don't actually need. If you have extras in your manifest, remove all of them.
Of course to get that popup you needed to ask for permissions at runtime. So somewhere you probably are using it.
This confuses me a lot when I test my app on android 6.0+ devices.Since in android 6.0+,we should ask the user to accept some dangerous permissions.I pressed refuse button when it ask me for
WRITE_EXTERNAL_STORAGE
permission and then,if my file cache path was data/data/com.myapp(getApplicationInfo().dataDir),it can still be cached. And for any other path e.g. Environment.getExternalStorageDirectory().getAbsolutePath(),it won't be cached.
So why does this happen?