Android 网络技术

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
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值