mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-19 06:10:56 +08:00
@ -131,3 +131,18 @@ export module ad {
|
|||||||
export function GC() {
|
export function GC() {
|
||||||
gc();
|
gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function openUrl(location: string): boolean {
|
||||||
|
var context = ad.getApplicationContext();
|
||||||
|
try {
|
||||||
|
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;
|
||||||
|
}
|
6
utils/utils.d.ts
vendored
6
utils/utils.d.ts
vendored
@ -173,4 +173,10 @@
|
|||||||
* @param source The JSON or JSONP string.
|
* @param source The JSON or JSONP string.
|
||||||
*/
|
*/
|
||||||
export function parseJSON(source: string): any
|
export function parseJSON(source: string): any
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens url.
|
||||||
|
* @param url The url.
|
||||||
|
*/
|
||||||
|
export function openUrl(url: string): boolean
|
||||||
}
|
}
|
||||||
|
@ -147,3 +147,17 @@ export module ios {
|
|||||||
export function GC() {
|
export function GC() {
|
||||||
__collect();
|
__collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function openUrl(location: string): boolean {
|
||||||
|
try {
|
||||||
|
var url = NSURL.URLWithString(location.trim());
|
||||||
|
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