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

Make AndroidNet#openURI compatible with targetSdk 30, fixes #6377 #6408

Merged
merged 2 commits into from Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
@@ -1,6 +1,7 @@
[1.9.15]
- Scene2d.ui: Added new ParticleEffectActor to use particle effects on Stage
- API addition: iOS: Added HdpiMode option to IOSApplicationConfiguration to allow users to set whether they want to work in logical or raw pixels (default logical).
- Fix for #6377 Gdx.net.openURI not working with targetSdk 30

[1.9.14]
- [BREAKING CHANGE] iOS: IOSUIViewController has been moved to its own separate class
Expand Down
Expand Up @@ -17,8 +17,8 @@
package com.badlogic.gdx.backends.android;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;

import com.badlogic.gdx.Net;
Expand Down Expand Up @@ -71,24 +71,18 @@ public Socket newClientSocket (Protocol protocol, String host, int port, SocketH

@Override
public boolean openURI (String URI) {
boolean result = false;
final Uri uri = Uri.parse(URI);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
PackageManager pm = app.getContext().getPackageManager();
if (pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
app.runOnUiThread(new Runnable() {
@Override
public void run () {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// LiveWallpaper and Daydream applications need this flag
if (!(app.getContext() instanceof Activity))
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
}
});
result = true;
try {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// LiveWallpaper and Daydream applications need this flag
if (!(app.getContext() instanceof Activity)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
app.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
return result;
}

}