Ads Top

Automatically Refresh your android activity

Make a global variable in your class.


private final Handler handler = new Handler();

Create a function to refresh activity

private void doTheAutoRefresh() {
    handler.postDelayed(new Runnable() {
             @Override
             public void run() {
                 doRefreshingStuff(); // this is where you put your refresh code
                 doTheAutoRefresh();                
             }
         }, 1000);
}

Now call this function in onCreate() and you are good to go




Powered by Blogger.