Skip to content

Commit 8444087

Browse files
fix(android): WebView url and event handling (#10147) (#10148)
closes #10147
1 parent 00944bb commit 8444087

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/core/ui/web-view/index.android.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ function initializeWebViewClient(): void {
2929

3030
// Handle schemes like mailto, tel, etc
3131
if (!android.webkit.URLUtil.isNetworkUrl(url)) {
32-
openUrl(url);
33-
return true;
32+
return openUrl(url);
3433
}
3534

3635
return false;

‎packages/core/utils/index.android.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ export function openUrl(location: string): boolean {
2222
const context = ad.getApplicationContext();
2323
try {
2424
const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(location.trim()));
25+
const packageManager = context.getPackageManager();
26+
2527
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
2628

29+
// Handle schemes like mailto, tel, etc
30+
if (intent.resolveActivity(packageManager) == null) {
31+
Trace.write('Unable to open ' + location + '. Make sure to add queries element(https://developer.android.com/guide/topics/manifest/queries-element) matching the scheme to the AndroidManifest.xml file.', Trace.categories.Error, Trace.messageType.error);
32+
return false;
33+
}
34+
2735
context.startActivity(intent);
2836
} catch (e) {
2937
// We Don't do anything with an error. We just output it

0 commit comments

Comments
 (0)