cocos2dx-js 调用本地浏览器

js端

if (cc.sys.os == cc.sys.OS_ANDROID) {

      jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "openUrl", "(Ljava/lang/String;)V",                         "http://down.lelegongshe.com/"); 

}

java端

import android.content.Intent;

import android.net.Uri;

static private AppActivity self = null;


public static void openUrl(String url)
{
    Uri uri = Uri.parse(url);
    Intent it = new Intent(Intent.ACTION_VIEW, uri);
    self.startActivity(it);


IOS

+(void) openBrowser: (NSString * )urlStr{

    NSString  *url = [NSString stringWithFormat:@"%@", urlStr];

    [[UIApplication sharedApplication] openURL :[NSURL URLWithString:url]];

}



你可能感兴趣的:(Cocos2dx-js)