NetworkOnMainThreadException error in jellybean

This question already has an answer here:

  • How do I fix android.os.NetworkOnMainThreadException? 49 answers

  • From Android API v15, it requires no heavy process working on main thread. So you should move your logic to another thread like bellow source code:

    new Thread(new Runnable() {
       public void run() {
            // your logic
       }                        
    }).start();
    

    More information please refer: Responsiveness


    just add this code in oncreate on which activity u call Asynck.

    code:-

    StrictMode.ThreadPolicy policy =
        new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    
    链接地址: http://www.djcxy.com/p/29536.html

    上一篇: Android中的Java客户端套接字连接

    下一篇: 在jellybean中出现NetworkOnMainThreadException错误