mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
@ -130,4 +130,19 @@ export module ad {
|
||||
|
||||
export function 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.
|
||||
*/
|
||||
export function parseJSON(source: string): any
|
||||
|
||||
/**
|
||||
* Opens url.
|
||||
* @param url The url.
|
||||
*/
|
||||
export function openUrl(url: string): boolean
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export module ios {
|
||||
var greenRef = new interop.Reference<number>();
|
||||
var blueRef = new interop.Reference<number>();
|
||||
var alphaRef = new interop.Reference<number>();
|
||||
|
||||
|
||||
uiColor.getRedGreenBlueAlpha(redRef, greenRef, blueRef, alphaRef);
|
||||
var red = redRef.value * 255;
|
||||
var green = greenRef.value * 255;
|
||||
@ -142,8 +142,22 @@ export module ios {
|
||||
rootView.measure(widthSpec, heightSpec);
|
||||
rootView.layout(left, top, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function GC() {
|
||||
__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