diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidNet.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidNet.java index 0703b2039f3..d45d1fbdfa7 100644 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidNet.java +++ b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidNet.java @@ -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; @@ -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; } }