Skip to content

Commit 74fe051

Browse files
fix(browser): crash when trying to open blob urls on android (#2274)
1 parent e8d8572 commit 74fe051

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

browser/android/src/main/java/com/capacitorjs/plugins/browser/BrowserPlugin.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,25 @@ public void open(PluginCall call) {
6060
}
6161

6262
// open the browser and finish
63-
try {
64-
Intent intent = new Intent(getContext(), BrowserControllerActivity.class);
65-
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
66-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
67-
getContext().startActivity(intent);
6863

69-
Integer finalToolbarColor = toolbarColor;
70-
setBrowserControllerListener(
71-
activity -> {
64+
Intent intent = new Intent(getContext(), BrowserControllerActivity.class);
65+
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
66+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
67+
getContext().startActivity(intent);
68+
69+
Integer finalToolbarColor = toolbarColor;
70+
setBrowserControllerListener(
71+
activity -> {
72+
try {
7273
activity.open(implementation, url, finalToolbarColor);
7374
browserControllerActivityInstance = activity;
7475
call.resolve();
76+
} catch (ActivityNotFoundException ex) {
77+
Logger.error(getLogTag(), ex.getLocalizedMessage(), null);
78+
call.reject("Unable to display URL");
7579
}
76-
);
77-
} catch (ActivityNotFoundException ex) {
78-
Logger.error(getLogTag(), ex.getLocalizedMessage(), null);
79-
call.reject("Unable to display URL");
80-
return;
81-
}
80+
}
81+
);
8282
}
8383

8484
@PluginMethod

0 commit comments

Comments
 (0)