Skip to content

Commit

Permalink
fix(android): crash when trying to open blob urls
Browse files Browse the repository at this point in the history
- when trying to open blob urls, an app using the @capacitor/browser plugin would just crash, with an `ActivityNotFoundException`
- the try/catch block wasn't placed properly

https://outsystemsrd.atlassian.net/browse/RMET-3912
  • Loading branch information
OS-martacarlos committed Dec 9, 2024
1 parent c6ddc53 commit 2d1838b
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ public void open(PluginCall call) {
}

// open the browser and finish
try {
Intent intent = new Intent(getContext(), BrowserControllerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);

Integer finalToolbarColor = toolbarColor;
setBrowserControllerListener(
activity -> {
Intent intent = new Intent(getContext(), BrowserControllerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);

Integer finalToolbarColor = toolbarColor;
setBrowserControllerListener(
activity -> {
try {
activity.open(implementation, url, finalToolbarColor);
browserControllerActivityInstance = activity;
call.resolve();
} catch (ActivityNotFoundException ex) {
Logger.error(getLogTag(), ex.getLocalizedMessage(), null);
call.reject("Unable to display URL");
}
);
} catch (ActivityNotFoundException ex) {
Logger.error(getLogTag(), ex.getLocalizedMessage(), null);
call.reject("Unable to display URL");
return;
}
}
);
}

@PluginMethod
Expand Down

0 comments on commit 2d1838b

Please sign in to comment.