如何在iOS中调用浏览器打开链接呢,代码如下
+ (BOOL)openUrl:(NSString*)urlString {
NSURL* url = [NSURL URLWithString:urlString];
if (!url) {
return NO;
}
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
return YES;
} else {
return NO;
}
}
在Android下的代码
/**
* Open a url by browser.
*
* @param context The context.
* @param url The url.
*/
public static void openUrl(Context context, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
context.startActivity(intent);
}