httpclient (phpmyadmin) not working on Android 4.0+

前端 未结 4 1055
北恋
北恋 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:36

    android.os.NetworkOnMainThreadException

    this eror comes With HoneyComb(3.0 or Later). you can not perform a networking operation on its main thread as documentation says. to getting ride of this you must use handler or asynctask. AFAIK There is no another way to do it.

    you can See this for More Details WHY ICS Crashes your App

    Try Using Below Code Snippet

    new Thread(){
        public void run(){
            //do your Code Here    
        }
    }.start();
    

提交回复
热议问题