diff options
author | ByteHamster <info@bytehamster.com> | 2019-09-25 15:00:33 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2019-09-25 15:00:33 +0200 |
commit | b65c688b53779f436062d33517f95b2c0a29733c (patch) | |
tree | ad9f655e28189741e88b13caa65d6e3895d003ca /core/src/main/java | |
parent | a92123340da7a3f7286adfd8510c868fec030d4e (diff) | |
download | AntennaPod-b65c688b53779f436062d33517f95b2c0a29733c.zip |
Fixed crash if there is no browser installed
Diffstat (limited to 'core/src/main/java')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java index e81ab47ed..656b518bf 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java @@ -1,13 +1,20 @@ package de.danoeh.antennapod.core.util; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.net.Uri; +import android.util.Log; +import android.widget.Toast; +import de.danoeh.antennapod.core.R; import java.util.List; public class IntentUtils { + private static final String TAG = "IntentUtils"; + private IntentUtils(){} /* @@ -28,4 +35,13 @@ public class IntentUtils { context.sendBroadcast(new Intent(action).setPackage(context.getPackageName())); } + public static void openInBrowser(Context context, String url) { + try { + Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + context.startActivity(myIntent); + } catch (ActivityNotFoundException e) { + Toast.makeText(context, R.string.pref_no_browser_found, Toast.LENGTH_LONG).show(); + Log.e(TAG, Log.getStackTraceString(e)); + } + } } |