title: Android permission - can't connect to internet
body: <p>I have problem. I had this manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="Svět Androida"
      android:theme="@style/MyMaterialTheme"&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="15"
          android:targetSdkVersion="22"/&gt;
      &lt;activity
          android:name=".welcomescreen"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity android:name=".MainActivity"&gt;
  
      &lt;/activity&gt;
  
      &lt;activity
          android:name=".Cteni"
          android:parentActivityName=".MainActivity" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value=".MainActivity" /&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>and application worked fine but when I wanted generate apk. It says </p>
  
  <blockquote>
    <p>uses-sdk must be child of manifest</p>
  </blockquote>
  
  <p>so i changed to this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;uses-sdk
      android:minSdkVersion="15"
      android:targetSdkVersion="22"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="Svět Androida"
      android:theme="@style/MyMaterialTheme"&gt;
      &lt;activity
          android:name=".welcomescreen"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity android:name=".MainActivity"&gt;
  
      &lt;/activity&gt;
  
      &lt;activity
          android:name=".Cteni"
          android:parentActivityName=".MainActivity" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value=".MainActivity" /&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>I generated apk successfully but when I start app it stops, because it can't connect to internet.</p>
  
  <p>edit: </p>
  
  <p>link on manifest:</p>
  
  <p><a href="https://onedrive.live.com/prev?id=9637B6BAC6554B19%211922&amp;cid=9637B6BAC6554B19&amp;parId=9637B6BAC6554B19%21109&amp;group=0&amp;v=TextFileEditor" rel="nofollow">https://onedrive.live.com/prev?id=9637B6BAC6554B19%211922&amp;cid=9637B6BAC6554B19&amp;parId=9637B6BAC6554B19%21109&amp;group=0&amp;v=TextFileEditor</a></p>
  
  <p>here is log with error:</p>
  
  <pre><code>08-04 11:15:02.966    2888-2888/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: simaproject.com.svetandroida, PID: 2888
  java.lang.RuntimeException: Unable to start activity ComponentInfo{simaproject.com.svetandroida/simaproject.com.svetandroida.MainActivity}: android.os.NetworkOnMainThreadException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
          at android.app.ActivityThread.access$800(ActivityThread.java:151)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:135)
          at android.app.ActivityThread.main(ActivityThread.java:5254)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
   Caused by: android.os.NetworkOnMainThreadException
          at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
          at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
          at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
          at java.net.InetAddress.getAllByName(InetAddress.java:215)
          at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
          at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
          at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
          at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:272)
          at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
          at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
          at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
          at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:199)
          at java.net.URL.openStream(URL.java:470)
          at simaproject.com.svetandroida.MainActivity.nactiData(MainActivity.java:78)
          at simaproject.com.svetandroida.MainActivity.onCreate(MainActivity.java:57)
          at android.app.Activity.performCreate(Activity.java:5990)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
              at android.app.ActivityThread.access$800(ActivityThread.java:151)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5254)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
  </code></pre>
  
  <p>Please help. Thanks.</p>