** SOLVED ** (see comments)
I’m updating a ProgressBar (declared in the Activity’s XML layout) through a Service running and notifying my Activity. Everything works fine in a first place when the Activity is first called. Then the Activity is finished through the finish() method, and the application continues to live its cycle.
Eventually this Activity is called again to perform the same operation. Problem is that the ProgressBar won’t show any progress ! I compared the ProgressBar’s vars on both instances of the Activity, exactly the same. I don’t get it, really. Any help would be appreciated.
MyActivity
ProgressBar progressBar;
public void onCreate(Bundle savedInstanceState) {
...
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
progressBar.setMax(100);
progressBar.setProgress(0);
...
}
public void get_info_from_service(...) {
progressBar.setProgress(service.getPercent());
}
void quit_activity{
Intent myIntent = new Intent(getBaseContext(), OtherActivity.class);
MyActivity.this.finish();
startActivity(myIntent);
}
MyService
for (Listener listener : listeners) {
listener.send_notification(this);
}
public int getPercent(){
return this.percent;
}
Solved. Always make sure you reinitiate your variables before entering the algorithm again !