Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can WRITE_EXTERNAL_STORAGE be optional? #268

Closed
vitto32 opened this issue Feb 19, 2020 · 6 comments
Closed

Can WRITE_EXTERNAL_STORAGE be optional? #268

vitto32 opened this issue Feb 19, 2020 · 6 comments

Comments

@vitto32
Copy link

vitto32 commented Feb 19, 2020

On Android WRITE_EXTERNAL_STORAGE permission is mandatory for recording audio.
Is it strictly necessary?

@francoisduchemin
Copy link

If I understand correctly, this is going to be an issue with Android 11: https://developer.android.com/about/versions/11/privacy/storage

If your app targets Android 11, both the WRITE_EXTERNAL_STORAGE permission and the WRITE_MEDIA_STORAGE privileged permission no longer provide any additional access.

It looks like the plugin write files to the external storage for Android... did you find an alternative, a solution?

@uareurapid
Copy link
Contributor

uareurapid commented Apr 28, 2021

any updates on this? This is a big issue for Android 11
thanks

@uareurapid
Copy link
Contributor

uareurapid commented Apr 29, 2021

For anyone interested I implemented a fix/workaround on my fork:
you can check it here: https://github.com/uareurapid/cordova-plugin-media/blob/master/src/android/AudioHandler.java
on private void promptForRecord()
And https://github.com/uareurapid/cordova-plugin-media/blob/master/src/android/AudioPlayer.java
Check references to if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)

Basically, for recording & saving audio it doesn't need WRITE_EXTERNAL_STORAGE permissions, if SDK >=29, as it will use scoped storage instead, and save the file in directories belonging to the app.

If the permissions were already granted before, or the SDk is lower it behaves as usual

Hope this helps others

@uaza
Copy link

uaza commented Sep 28, 2021

@uareurapid Your change has worked for us, thank you. Can you maybe create a pull request here, that would be great!

@21pg
Copy link

21pg commented Sep 29, 2021

For anyone interested I implemented a fix/workaround on my fork: you can check it here: https://github.com/uareurapid/cordova-plugin-media/blob/master/src/android/AudioHandler.java on private void promptForRecord() And https://github.com/uareurapid/cordova-plugin-media/blob/master/src/android/AudioPlayer.java Check references to if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)

Basically, for recording & saving audio it doesn't need WRITE_EXTERNAL_STORAGE permissions, if SDK >=29, as it will use scoped storage instead, and save the file in directories belonging to the app.

If the permissions were already granted before, or the SDk is lower it behaves as usual

Hope this helps others

I don't required to record and play.
We use live stream e.g (-[(http://streams.radiobob.de/bob-chillout/aac-64/streams.radiobob.de/)])
and just want to play this audio stream on button click..
When I click play button, output is: Error: 1
here-
#315

@breautek breautek added this to To do in 6.x via automation Apr 12, 2022
@erisu
Copy link
Member

erisu commented May 25, 2022

This permission has been removed in main branch and will be drop starting from version 6.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
6.x
Done
Development

No branches or pull requests

7 participants