Android 网络技术

xiaoxiao2021-02-28  33

1.WebView 首先在activity_main.xml中修改

<WebView android:id="@+id/web_view" android:layout_width="match_parent" android:layout_height="match_parent"/>

然后我们只需要在MainActivity中

WebView webView = (WebView)findViewById(R.id.web_view); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WenViewClient()); webView.loadUrl("http://www.baidu.com");

对于Android中的Http的协议首先

URL url = new URL("http://www.baidu.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection();

在得到了HttpURLConnection实例后,我们需要设置HTTP的请求方式,通常有两种GET和POST

connection.setConnectTimeout(8000);//一些设置 connection.setReadTimeout(8000); InputStream in = connection.getInputStream();//得到服务器返回的输入流 connection.disconnect();

sax解析 JSON GSON

转载请注明原文地址: https://www.6miu.com/read-2614765.html

最新回复(0)