Wednesday, July 11, 2012

Exception "android.os.NetworkOnMainThreadException" !


This is common in android to get error on http or networking connection with this message "android.os.NetworkOnMainThreadException" . 
This exception is thrown when an application attempts to perform a networking operation on its main thread .
Run your code in AsyncTask that will solve your problem:

Hints: 
           Thread msgThread = new Thread(){
            
            public void run(){
                  
                        http.httpConnectionMsg(nvp,is,msgurl);
            }   
}

msgThread.start();

1 comment:

  1. Thread msgThread = new Thread(){

    public void run(){
    http.httpConnectionMsg(nvp,is,msgurl);
    }
    };

    msgThread.start();

    ReplyDelete