mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
code updated
This commit is contained in:
@@ -132,9 +132,17 @@ export function GC() {
|
|||||||
gc();
|
gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openUrl(url: string): void {
|
export function openUrl(location: string): boolean {
|
||||||
var context = ad.getApplicationContext();
|
var context = ad.getApplicationContext();
|
||||||
if (context) {
|
try {
|
||||||
context.startActivity(new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url)));
|
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(location.trim()));
|
||||||
|
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
|
context.startActivity(intent);
|
||||||
|
} catch (e) {
|
||||||
|
// We Don't do anything with an error. We just output it
|
||||||
|
console.error("Error in OpenURL", e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
2
utils/utils.d.ts
vendored
2
utils/utils.d.ts
vendored
@@ -178,5 +178,5 @@
|
|||||||
* Opens url.
|
* Opens url.
|
||||||
* @param url The url.
|
* @param url The url.
|
||||||
*/
|
*/
|
||||||
export function openUrl(url: string): void
|
export function openUrl(url: string): boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,9 +148,16 @@ export function GC() {
|
|||||||
__collect();
|
__collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openUrl(url: string): void {
|
export function openUrl(location: string): boolean {
|
||||||
var sharedApp = UIApplication.sharedApplication()
|
try {
|
||||||
if (sharedApp) {
|
var url = NSURL.URLWithString(location.trim());
|
||||||
sharedApp.openURL(NSURL.URLWithString(url));
|
if (UIApplication.sharedApplication().canOpenURL(url)) {
|
||||||
|
return UIApplication.sharedApplication().openURL(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
// We Don't do anything with an error. We just output it
|
||||||
|
console.error("Error in OpenURL", e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user