httpclient (phpmyadmin) not working on Android 4.0+

前端 未结 4 1063
北恋
北恋 2021-01-27 09:12

I use this code below, it works perfectly in Android 2.3.3. However, in 4.0+ it can\'t connect to database somehow. I saw some posts about you need to get it in a asynch class.

4条回答
  •  一个人的身影
    2021-01-27 09:31

    Since Android 3.0 you are not allowed to do network stuff on the main thread. Why? because network problems will lead to a slow ui. So you have to do all the http stuff in a new thread. You are on the right path but you made a mistake in your AsyncTask. Delete the empty doInBackground method in you async task and write @Override over your method.

提交回复
热议问题