From f29dff79e9fc147e9fac4096f3238b5a2d03987b Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 9 Jun 2021 17:28:11 +0200 Subject: [PATCH] Use chooser for open link with --- .../eu/faircode/email/FragmentDialogOpenLink.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java index 0fbf2cfbd6..a2e3676c7e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.app.Dialog; +import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -355,8 +356,16 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { .setNeutralButton(R.string.title_browse, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + // https://developer.android.com/training/basics/intents/sending#AppChooser Uri uri = Uri.parse(etLink.getText().toString()); - Helper.view(context, uri, true, true); + Intent view = new Intent(Intent.ACTION_VIEW, uri); + Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app)); + try { + startActivity(chooser); + } catch (ActivityNotFoundException ex) { + Log.w(ex); + Helper.view(context, uri, true, true); + } } }) .setNegativeButton(android.R.string.cancel, null)