Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

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();
            }
        });


Android - Run/install/debug applications over WiFi

I was very tired to Install app through USB so I was wondering it would be cool if I can install apk over wifi and I found the solution:

  1. Connect device via USB and make sure debugging is working.
  2. adb tcpip 5555
  3. adb connect <DEVICE_IP_ADDRESS>:5555
  4. Disconnect USB and proceed with wireless debugging.
  5. adb -s <DEVICE_IP_ADDRESS>:5555 usb to switch back when done.
No root required!
To find the IP address of the device: run ./adb shell and then netcfg. You'll see it there.