I know similar questions have been asked several times here, but I am looking for a workaround.
Considering the "Share"-function. Apps like Google Photos and others grant uri permissions for receiving-app components (i.e. the launched activity which is registered as share receiver). My "share receiver" needs to save data to the disk and thus hands on the uri to a service that handles saving in the background. However, this is where it gets nasty. When the originally permission-granted activity dies / is not in foreground, the uri permission is revoked and the service throws a Securiy Exception when trying to access the data.
My standard approach is to keep the activity alive, as I've not found any work around yet. However, I don't have any indicator (other than a list of "bad" providers from my experience) to check if this is needed, as I don't want to have the activity need to stay alive for all files.
TLDR: So: Is there a way to either
- a) "transfer" the uri permission to the background service to avoid the activity-stay-alive workaround
- or b) check if the current context has permissions / which components have permission to access / need to stay alive ... etc.
Thanks in advance!