I am a beginner in android app developing.
I have to use ping test in my app for checking available internet connection as I have found this method very useful, but I read at many places that I should use AsyncTask() method or Handler() method as ping test on UI thread may freeze my app.
But I am not getting the difference between those two to decide which one I should use. I found that in AsyncTask, I have methods like doInBackground() and onPostExecute which helps in interaction with UI thread and processes run in another thread.
But I am not getting such methods in Handler() method.
Handler handler = new Handler();
Runnable runnable =new Runnable() {
@Override
public void run() {
handler.postDelayed(this,1000);
}
};
handler.post(runnable);
- I am not getting which method in Handler() is running in background and which method are helpful for making the app run in background like I found in AsyncTask().
- I am not understanding the difference between those two.