MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / openUrl

Function openUrl

packages/core/utils/index.android.ts:63–77  ·  view source on GitHub ↗
(location: string)

Source from the content-addressed store, hash-verified

61}
62
63export function openUrl(location: string): boolean {
64 const context = androidUtils.getApplicationContext();
65 try {
66 const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(location.trim()));
67 intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
68 context.startActivity(intent);
69 } catch (e) {
70 // We don't do anything with an error. We just output it
71 Trace.write(`Failed to start activity for handling URL: ${location}`, Trace.categories.Error, Trace.messageType.error);
72
73 return false;
74 }
75
76 return true;
77}
78
79export function openUrlAsync(location: string): Promise<boolean> {
80 return new Promise<boolean>((resolve, reject) => {

Callers

nothing calls this directly

Calls 3

startActivityMethod · 0.80
parseMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected