As part of the application i m building an audio player with Service and Broadcast to update the media player. everything is fine but the seekbar movement is not smooth. This is how i send the seekbar position from service to activity
private final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (mp != null) {
int progress = (mp.getCurrentPosition() * 100)
/ mp.getDuration();
Integer i[] = new Integer[3];
i[0] = mp.getCurrentPosition();
i[1] = mp.getDuration();
i[2] = progress;
try {
PlayerConstants.PROGRESSBAR_HANDLER
.sendMessage(PlayerConstants.PROGRESSBAR_HANDLER
.obtainMessage(0, i));
} catch (Exception e) {
}
}
}
};
and in the activity, seekbar is updated like this
PlayerConstants.PROGRESSBAR_HANDLER = new Handler() {
@Override
public void handleMessage(Message msg) {
Integer i[] = (Integer[]) msg.obj;
seekBar.setProgress(i[2]);
}
};
how could i modify this code to make the movement smooth.thanks in advance