You need to get the result of the GET query in Android and return the value from the method. Resolved! Thank you all for participating!
public void sayHello(View view)throws IOException { Thread httpThread = new Thread(new Runnable() { public void run() { String mybla = sendGet(); } }); httpThread.start(); } private String sendGet(){ try{ String mystr = "http://www.pravda.com.ua"; URL obj = new URL(mystr); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); con.setRequestProperty("User-Agent", "Mozilla/5.0"); con.setRequestProperty("Accept-Charset", "UTF-8"); InputStream response = con.getInputStream(); Scanner s = new Scanner(response).useDelimiter("\\A"); String result = s.hasNext() ? s.next() : ""; return result; } catch (Exception e) { return e.toString(); } }
OkHttp- YuriySPb ♦