Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android2-员振寰-1414010444 #35

Open
A-L-L-A-L-L opened this issue Jan 3, 2016 · 0 comments
Open

Android2-员振寰-1414010444 #35

A-L-L-A-L-L opened this issue Jan 3, 2016 · 0 comments

Comments

@A-L-L-A-L-L
Copy link

1、通过其它应用隐式启动Activity访问BaiDu

//点击按钮后跳转,用浏览器打开链接
public  void click(View v) {
        String url = "http://www.baidu.com"; // web address
        Intent intent = new Intent(Intent.ACTION_VIEW);//设置隐式启动activity
        intent.setData(Uri.parse(url));
        startActivity(intent);
}
public void click(View v){
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
        startActivity(intent);
}

2、通过本应用隐式启动Activity访问BaiDu

private WebView myWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        myWebView = (WebView) findViewById(R.id.webView);
        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.loadUrl("https://www.baidu.com");
}
<!--如果是本应用,需要在AndroidManifest.xml增加访问网络的权限-->
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant