The idea is for my runnable to run every minute.
Instead, it runs in roughly about 20 seconds and I have no idea why.
Below is the code:
final Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
try{
//Post from Queue & update post
if (NetworkUtils.isConnected()) {
//post from queue
try {
postHelper.postFromQueue();
} catch (IOException e) {
e.printStackTrace();
}
//Update posts
postHelper.updateSolicitations();
}
}
catch (Exception e) {
// TODO: handle exception
}
finally{
//also call the same runnable to call it at regular interval
handler.postDelayed(this, 60000);
}
}
};
I don't know if it's relevant but it's onCreate method of MainActivity.