URL url = new URL(URL path);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setConnectTimeout(30000);
connection.setReadTimeout(30000);
connection.setDoInput(true);
connection.setUseCaches(true);
connection.connect();
InputStream is = connection.getInputStream();
Above code is my code of Android.
I try to connect an URL path and get information to InputStream is.
I try to connect the same URL path with the same wifi by Android phone and iPhone.
Android phone spend about 10 seconds by moto phones or HTC phones.
But iPhone only spend less than 3 seconds.
I think it may not only cause by wifi speed.(Because I try with the same wifi).
So I want to ask that is it possible improved by code?
Try using the apache
HttpClientinstead ofURL.openConnection()Edit:
In API level 22 (Android M) the Apache HttpClient will be removed, so this approach is deprecated.
For more infor see :
http://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client
The recommended approach is to use
HttpUrlConnection(http://developer.android.com/reference/java/net/HttpURLConnection.html):