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

Function openUrlAsync

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

Source from the content-addressed store, hash-verified

77}
78
79export function openUrlAsync(location: string): Promise<boolean> {
80 return new Promise<boolean>((resolve, reject) => {
81 try {
82 const context = androidUtils.getApplicationContext();
83 const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(location.trim()));
84 intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
85 context.startActivity(intent);
86 resolve(true);
87 } catch (e) {
88 // We don't do anything with an error. We just output it
89 Trace.write(`Failed to start activity for handling URL: ${location}`, Trace.categories.Error, Trace.messageType.error);
90 resolve(false);
91 }
92 });
93}
94
95/**
96 * Check whether external storage is read only

Callers

nothing calls this directly

Calls 4

startActivityMethod · 0.80
parseMethod · 0.65
writeMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected