Runs the specified action on the UI thread. If the current thread is the UI thread, then the action is executed immediately. If the current thread is not the UI thread, the action is posted to the event queue of the UI thread.
for more info about runOnUiThread check http://developer.android.com/reference/android/app/Activity.html#runOnUiThread%28java.lang.Runnable%29
just put your code in
runOnUiThread(new Runnable() {
@Override
public void run() {
//put code here
}
Try using [runOnUiThread](http://developer.android.com/reference/android/app/Activity.html#runOnUiThread%28java.lang.Runnable%29)
Runs the specified action on the UI thread. If the current thread is the UI thread, then the action is executed immediately. If the current thread is not the UI thread, the action is posted to the event queue of the UI thread.
runOnUiThread(new Runnable(){
@Override
public void run(){
// change UI elements here
//ping()
}
});