on develop help sign in
Merge pull request #220 from eskimor/dont-crash-on-unknown-intent

Don't crash if URI cannot be handled by Android.

commit8e615a8a57cbb492f73dc9e6966c0cb865679c4d authorLuigy Leon <luichi.19@gmail.com> dateWed 9 Jan 2019, 18:23 (8 years ago) parent0be40cf9e0fc93
1 file changed+7−1
reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java+7−1
reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java+7−1
@@ -21,6 +21,7 @@ import android.graphics.Bitmap;
2121import java.io.IOException;
2222import java.io.InputStream;
2323import android.content.Intent;
24+import android.content.ActivityNotFoundException;
2425
2526import java.nio.charset.StandardCharsets;
2627
@@ -79,7 +80,12 @@ public class MainWidget {
7980 @Override
8081 public boolean shouldOverrideUrlLoading(WebView view, String url) {
8182 if( url != null && !url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("file://")) {
82− view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
83+ try {
84+ view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
85+ }
86+ catch(ActivityNotFoundException e) {
87+ Log.e("reflex", "Starting activity for intent '" + url + "' failed!");
88+ }
8389 return true;
8490 } else {
8591 return false;