HttpURLConnection fails on Android 4.0

后端 未结 2 986
后悔当初
后悔当初 2021-01-19 15:56

I am using this code to fetch my changelog from the net.

InputStream content = null;
           try {


               URL url = new URL(\"http://dreamhawk.b         


        
2条回答
  •  逝去的感伤
    2021-01-19 16:29

    I know in android 3.0 network connection on the main thread isnt permitted.

    StrictMode is turned on automatically. Im sure it is the same for 4.0

    To fix the issue, you must perform the network connection on a separate thread... for example, using an AsyncTask.


    Read this blog post on the subject:

    Why Ice Cream Sandwich Crashes Your App

提交回复
热议问题