Handler Example in android Or Calling the method according to time interval Or Calling method every 1 minute...
private static int DATA_INTERVAL = 60 *1000;
//Creating an Object of Handler
Handler _handler;
_handler = new Handler();
//Used for removing call back .(the method we have register using postDelayed used to stop.).
_handler.removeCallbacks(getData);
//Used for calling method according to time.
_handler.postDelayed(getData, DATA_INTERVAL);
//Method which will be called accroding to time
private final Runnable getData = new Runnable() {
public void run() {
getTimeCalculate();
}
};
//Method which will be called after 1 Minute
private void getTimeCalculate() {
Log.d("Hi I am called","Please check the log")
}
Thanks Enjoy all who is facing this type of issue,if you like the post or dont like leave your comment,so we will try to give our best post which will be helpful for android developers.
private static int DATA_INTERVAL = 60 *1000;
//Creating an Object of Handler
Handler _handler;
_handler = new Handler();
//Used for removing call back .(the method we have register using postDelayed used to stop.).
_handler.removeCallbacks(getData);
//Used for calling method according to time.
_handler.postDelayed(getData, DATA_INTERVAL);
//Method which will be called accroding to time
private final Runnable getData = new Runnable() {
public void run() {
getTimeCalculate();
}
};
//Method which will be called after 1 Minute
private void getTimeCalculate() {
Log.d("Hi I am called","Please check the log")
}
Thanks Enjoy all who is facing this type of issue,if you like the post or dont like leave your comment,so we will try to give our best post which will be helpful for android developers.
No comments:
Post a Comment