This question has already been answered:
The application contains 1 Activity , the onCreate method contains the following code:
int c; URL myUrl = null; try { myUrl = new URL("http://www.pro-java.ru"); } catch (MalformedURLException e) { e.printStackTrace(); } URLConnection myUrlCon = null; try { myUrlCon = myUrl.openConnection(); } catch (IOException e) { e.printStackTrace(); } long length = myUrlCon.getContentLength(); String data = ""; if(length != 0) { InputStream input = null; try { input = myUrlCon.getInputStream(); } catch (IOException e) { e.printStackTrace(); } try { while(((c = input.read()) != -1)) { data = data.concat(String.valueOf(c)); } } catch (IOException e) { e.printStackTrace(); } try { input.close(); } catch (IOException e) { e.printStackTrace(); } } Manifesto:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tcptest"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> What can be caused by the departure?