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
Android openURI(...) not working on Android 11 #6377
Comments
Just tested on an R emulator, it still works for me. The only difference in your code and the backend code I spotted is the check if there is a handler for the URI. You mention something about live wallpapers, how does that relate to opening an URI? |
I updated the comment. I believe this happens only if the libGDX project is set to Android 11 (30). I didn't have the problem before but changing to SDK 30 makes the problem occur. Unless there is something else bad happening in my project. |
Checked it, it is working for me with targetSdk 30 on Android R emulator |
What type of uri is it? Just a normal web url? |
Yes, it's normal Maybe the I was able to reproduce it on a fresh emulator for Nexus 6P and SDK 30. |
Can you check by stepping through it with the debugger? You should be able to see if the command is not executed or if it fails. |
Using a Pixel emulator on Android 11, with the Android tests set to target API 30, this is reproducible via NetAPITest. Android 11 added some 'privacy' around package visibility, which requires specifying in the AndroidManifest.xml the type of intent queries you will perform - the backend code performs a query to see if any activity can resolve. Adding this to the AndroidManifest.xml makes openURI work:
The reason it works with the proposed solution is that you are not querying for installed packages and the system makes an exception in the case where you just fire off a startActivity call - this is not without some trouble though as there is some very strange behavior that comes along with this for some types of URIs. |
@MobiDevelop Thanks, I wasn't aware of that! I guess this works. Also, I am using @MrStahlfelge Good point, I should have debugged that further myself. Adding |
The system behaves oddly, at least it did for me with a |
I was able to reproduce this with a fresh emulator, too. The code @noblemaster gave in the OP works for me, too, or a slightly different variant:
According to stackoverflow, using the |
Ah found it, it is not precaution but to make openUri threadsafe: #59 (comment) |
Issue details
Android's openURI is not working on Android 11 anymore. Calling
openURI(...)
does nothing. There is no error thrown.Version of LibGDX and/or relevant dependencies
Latest stable release 1.9.13. The Android project has to be set to Android 11 (30).
Suggestion for Code Fix
A quick test showed the following code works. The live wallpaper flag needs to be set. Also, does this really need to run via UI thread as in libGDX's example?
Please select the affected platforms
The text was updated successfully, but these errors were encountered: