There is the easiest HttpClient
public class HttpClient { Context ctx; AntoninHttpClient httpClient; public HttpClient(Context c){ this.ctx=c; } public void get(String url,AntoninHttpClient a){ this.httpClient = a; MyTask m = new MyTask(); m.execute(url); } class MyTask extends AsyncTask<String, Void, String> { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(String... params) { HttpsURLConnection urlConnection = null; BufferedReader reader = null; String resultJson = "0"; try { URL url = new URL(params[0]); urlConnection = (HttpsURLConnection) url.openConnection(); //urlConnection.setRequestMethod("GET"); urlConnection.connect(); InputStream inputStream = urlConnection.getInputStream(); StringBuffer buffer = new StringBuffer(); reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { buffer.append(line); } resultJson = buffer.toString(); return resultJson; } catch (IOException e) { return null; } } @Override protected void onPostExecute(String result) { super.onPostExecute(result); if(result!=null){ httpClient.onData(result);}else{ httpClient.onError("not"); } } } public interface AntoninHttpClient { public void onData(String data); public void onError(String error); } } If you send a request, for example at https://api.vk.com/method/users.get.xml?user_ids=210700286&fields=bdate&v=5.53 everything is fine, the answer comes, but if I send a request to http: // ***. 16mb.com/login.php (this is my site on free hosting, there I am testing the application) knocks out an error (the application is closed). What can be problematic?
login.php <?php echo "Test"; ?> This is the last entry in the logs.
08-03 14:10:44.690 7087-7671/com.example.antonin.feeling D/dalvikvm: GC_FOR_ALLOC freed 479K, 23% free 2995K/3872K, paused 7ms, total 7ms 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: java.lang.ClassCastException: com.android.okhttp.internal.http.HttpURLConnectionImpl cannot be cast to javax.net.ssl.HttpsURLConnection 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at com.example.antonin.feeling.core.HttpClient$MyTask.doInBackground(HttpClient.java:40) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at com.example.antonin.feeling.core.HttpClient$MyTask.doInBackground(HttpClient.java:24) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 08-03 14:10:44.700 7087-7671/com.example.antonin.feeling W/System.err: at java.lang.Thread.run(Thread.java:841)