Tuesday, April 28, 2015

Android "android.os.NetworkOnMainThreadException" error

Last night I was trying to insert value from Android to MySQL but I could not manage to do it and finally after kill 2 hour I found the solution. For new Android OS we need thread. So if you want to send value you should follow:

            public void onClick(View v) {
                new Thread(new Runnable() {
                    public void run() {
                       //Do your operation here like insert();
                    }
                }).start();
            }
        });


No comments:

Post a Comment