Android openURI(...) not working on Android 11
See original GitHub issueIssue 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?
try {
// open with the correct activity if any
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
catch (Exception e) {
// ... log error...
return false;
}
Please select the affected platforms
- [x ] Android 11
- iOS
- HTML/GWT
- Windows
- Linux
- MacOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Simple AndroidApp to open a web link is not working
On Android 11 and above there are limitation to querying other packages. ... getPackageManager()) fails and the startActivity() is not ...
Read more >Device.OpenURI not working on Android 9? - MSDN - Microsoft
I loaded up my app in an Android 9 emulator, and sure enough, it doesn't open ... OpenUri(uri); worked fine, using a URI...
Read more >Common Intents - Android Developers
An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view...
Read more >url_launcher | Flutter Package - Pub.dev
A Flutter plugin for launching a URL. Android, iOS, Linux, macOS, Web, Windows. Support, SDK 16+, 9.0+, Any ...
Read more >Android API level 30 is here in 3651 - Solar2D Forums
... 3651 since 3650 had issues with Google License Checking Android API level 30 Android introduced breaking change in Android 11 (api 30) ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah found it, it is not precaution but to make openUri threadsafe: https://github.com/libgdx/libgdx/pull/59#issuecomment-9296572 I don’t see much benefit in having a UI operation threadsafe though.
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
queries
is needed when you need to know if there are applications, but not start them. We don’t have the situation here, and I am sure runOnUiThread is not needed. It was not introduced because of crash reports but from the beginning, probably out of precaution (5ef9a9ef)