Академический Документы
Профессиональный Документы
Культура Документы
http://www.vogella.com/articles/AndroidNetworking/article.html
104
java.net
java.net
HttpURLConnection HttpURLConnection
1 of 4
6/1/2013 1:26 PM
http://www.vogella.com/articles/AndroidNetworking/article.html
android.permission.ACCESS_NETWORK_STATE
onCreate()
StrictMode.ThreadPolicy policy = new StrictMode. ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
HttpURLConnection
// Somewhere in your code this is called // in a thread which is not the user interface // thread
try { URL url = new URL("http://www.vogella.com"); HttpURLConnection con = (HttpURLConnection) url .openConnection(); readStream(con.getInputStream()); } catch (Exception e) { e.printStackTrace(); }
private void readStream(InputStream in) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(in)); String line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) {
2 of 4
6/1/2013 1:26 PM
http://www.vogella.com/articles/AndroidNetworking/article.html
HttpURLConnection
ACCESS_NETWORK_STATE
Settings onCreate
Settings.System.putString(getContentResolver(), Settings.System.HTTP_PROXY, "myproxy:8080");
android.permission.WRITE_SETTINGS
AndroidManifest.xml
3 of 4
6/1/2013 1:26 PM
http://www.vogella.com/articles/AndroidNetworking/article.html
4 of 4
6/1/2013 1:26 PM