In order to prevent the UI thread from being unresponsive in Android, network traffic generally uses Asynctask (the lightweight asynchronous Operation class in Android), which is no longer elaborated in this article.
Body Start
New Asynctask<string,void,void> () {@Override protected Void doinbackground (String ... params) { try {URL url = new URL (params[0]); URLConnection connection = Url.openconnection (); InputStream is = Connection.getinputstream (); InputStreamReader ISR = new InputStreamReader (IS, "utf-8"); BufferedReader br = new BufferedReader (ISR); String Line; while (line = Br.readline ())! = null) {System.out.println (line); } br.close (); Isr.close (); Is.close (); } catch (Malformedurlexception e) {e.printstacktrace (); } catch (IOException e) {e.printstacktrace (); } return null; }}.execute ("Http://fanyi.youdao.com/openapi.do?keyfrom=jin123d1&key=" own Key "&type=data&doctype= json&Amp;version=1.1&q=good ");
Here used Youdao Translation API (oneself can go to Youdao translation Official website application)
After the completion of the implementation can be in the logcat to hear the Youdao translation of Chinese content
Android reads network data using the Get mode of HTTP