I want the time to increase progress regularly and apply every time the variable value is 50. I mean, every step of the increase can be controlled with a certain amount
How do I do this by a Handler on Android?
if ( progress == 50 && progress == 100 && progress == 150 ... )
do setProgress
In the example above, every step is 50
My code is here and use my custom progress in Handler :
private Handler mIncomingHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
if (REQUEST_TIMER == 0) {
if (msg.what == 0) {
if (progress < 100) {
progress++;
progress_bar.setProgress(progress);
if (progress == 99)
CustomActivity.this.finish();
}
}
} else if (msg.what == 0) {
if (progress < 100) {
progress++;
progress_bar.setProgress(progress);
}
}
return false;
}
});
I don't know what is your requirement,Hope this may help you
In my case i am updating a progress bar based on audio file position playing in a media player 'mp' so i used the following code.
progress_bar.setMax(100);
if(mp.getDuration()!=0) {
progress_bar.setProgress(100 * mp.getCurrentPosition() / mp.getDuration());
}