USING INTERNET RESOURCES

There are a number of benefits to creating thick- and thin-client native applications rather than relying
on entirely web-based solutions:

Bandwidth  Caching  Native features

 

Mobile Internet GPRS, EDGE, and 3G Internet access is available through carriers that
offer mobile data plans.
Wi-Fi Wi-Fi receivers and mobile hotspots are becoming increasingly common.

 

Connecting to an Internet Resource

<uses-permission android:name="android.permission.INTERNET"/>

String myFeed = getString(R.string.my_feed);
try {
URL url = new URL(myFeed);
URLConnection connection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection)conne
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpConnection.getInputStream();
[ ... Process the input stream as required ... ]
}
}
catch (MalformedURLException e) { }
catch (IOException e) { }

 

阅读更多
个人分类: Android
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭