String myURL = new String("http://4pda.ru"); textViewSendText.setText("Hello"); HttpURLConnection connection = null; try { textViewSendText.setText("1"); URL url = new URL(myURL); textViewSendText.setText("2"); connection = (HttpURLConnection)url.openConnection(); textViewSendText.setText("3"); connection.setRequestMethod("GET"); connection.setUseCaches(false); textViewSendText.setText("4"); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.setDoInput(true); DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); connection.connect(); int responseCode = connection.getResponseCode(); textViewSendText.setText(Integer.toString(responseCode)); InputStream response = connection.getInputStream(); } catch (Exception e){ } finally { } 

I try to make the simplest query, but nothing happens. The program stops at connection.getOutputStream or connect . I tried to run from a real device and from an emulator - the same thing happens. In the manifesto I registered everything that is needed, nothing helps.

Here is the output when you press the button:

  05-24 15:54:20.466 22553-22553/? W/Zygote: mz_is_rooted false 05-24 15:54:20.469 22553-22553/? I/art: Late-enabling -Xcheck:jni 05-24 15:54:20.743 22553-22553/com.example.uncolor.yandextranslator E/System: stat file error, path is /data/app/com.example.uncolor.yandextranslator-2/lib/arm64, exception is android.system.ErrnoException: stat failed: ENOENT (No such file or directory) 05-24 15:54:20.747 22553-22553/com.example.uncolor.yandextranslator I/InstantRun: starting instant run server: is main process 05-24 15:54:20.878 22553-22553/com.example.uncolor.yandextranslator W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 05-24 15:54:21.264 22553-22590/com.example.uncolor.yandextranslator E/GED: Failed to get GED Log Buf, err(0) [ 05-24 15:54:21.264 22553:22590 I/ ] elapse(include ctx switch):3363 (ms), eglInitialize 05-24 15:54:21.264 22553-22590/com.example.uncolor.yandextranslator I/OpenGLRenderer: Initialized EGL, version 1.4 05-24 15:54:21.275 22553-22590/com.example.uncolor.yandextranslator I/OpenGLRenderer: Get enable program binary service property (1) 05-24 15:54:21.275 22553-22590/com.example.uncolor.yandextranslator I/OpenGLRenderer: Initializing program atlas... 05-24 15:54:21.277 22553-22590/com.example.uncolor.yandextranslator I/OpenGLRenderer: Program binary detail: Binary length is 169916, program map length is 152. 05-24 15:54:21.277 22553-22590/com.example.uncolor.yandextranslator I/OpenGLRenderer: Succeeded to mmap program binaries. File descriptor is 54, and path is /dev/ashmem . 05-24 15:54:21.277 22553-22590/com.example.uncolor.yandextranslator I/OpenGLRenderer: No need to use file discriptor anymore, close fd(54). 05-24 15:54:21.297 22553-22553/com.example.uncolor.yandextranslator W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 05-24 15:54:21.338 22553-22590/com.example.uncolor.yandextranslator W/MALI: glDrawArrays:714: [MALI] glDrawArrays takes more than 5ms here. Total elapse time(us): 12143 05-24 15:55:00.061 22553-22553/com.example.uncolor.yandextranslator I/System.out: open:http://4pda.ru 05-24 15:55:00.066 22553-22553/com.example.uncolor.yandextranslator D/libc-netbsd: [getaddrinfo]: mtk hostname=4pda.ru; servname=(null); cache_mode=(null), netid=0; mark=0 05-24 15:55:00.066 22553-22553/com.example.uncolor.yandextranslator D/libc-netbsd: getaddrinfo( app_uid:10117 05-24 15:55:00.066 22553-22553/com.example.uncolor.yandextranslator D/libc-netbsd: getaddrinfo() uid prop: 05-24 15:55:00.066 22553-22553/com.example.uncolor.yandextranslator D/libc-netbsd: getaddrinfo() getuid():10117 05-24 15:55:00.066 22553-22553/com.example.uncolor.yandextranslator D/libc-netbsd: [getaddrinfo]: mtk ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 
  • I think here is much more extensive problems. Starting from the fact that maybe your request is executed in the UI thread, well, or you are trying to update the TextView widget directly from another thread - Chaynik
  • I'm new to android. I would be grateful if you explain my mistakes - Vlad Sapozhnikov
  • The code is executed in the onClick method - Vlad Sapozhnikov
  • Show the full stack trace. - post_zeew
  • Added everything that was - Vlad Sapozhnikov

0