Social Distancing for Apps
With Android 11, this is no longer the case.
Suppose, as in the latter example above, you have written two apps. The user assures you that both apps are installed. With Android 11, by default, you have no means of verifying from one app that the other app is installed. And, with Android 11, by default you will not be able to communicate between those apps. In the case from above, the client app cannot bind to the service app, even with a properly-constructed Intent
.
(How does the author know this? The author beat his head against a wall for an hour trying to figure out why the sample wouldn’t run, before remembering this new restriction…)
There are ways to whitelist certain things that will allow your app to see other apps. And there is an option to eliminate this restriction entirely. However, as you will see, neither are complete solutions — you should assume that the original forms of interoperability available to Android apps before will not be available to you going forward.
Also note that there are a number of other built-in limits on this restriction:
- If you start an activity using an implicit
Intent
(e.g.,ACTION_VIEW
on someUri
), that is allowed - If you provide a fine-grained permission grant, such as
FLAG_GRANT_READ_URI_PERMISSION
on aUri
fromFileProvider
, the recipient can use that grant (e.g., open the content identified by theUri
) - If you can talk to an app, the app can respond along that same IPC channel (e.g.,
setResult()
in response to astartActivityForResult()
call) - You can talk among your own app’s processes without restrictions
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.