After a long time finally i got to know that how to update progress bar while button is being pressed. This code is not work for gingerbread. and all the other OS it works fine. in-case of any question you may ask enjoy!!!!
button.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
if(arg1.getAction()==MotionEvent.ACTION_DOWN){
arg0.post(rotationRunnable);
}
return false;
}
});
RotationRunnable Method :-
private Runnable rotationRunnable = new Runnable() {
@Override
public void run() {
if (button.isPressed()) {
try{
if(mProgressStatus<100){
Thread.sleep(500);
mProgressStatus = doWork();
pB.setProgress(mProgressStatus);
}
}catch(Exception e) {
e.printStackTrace();
}
button.postDelayed(rotationRunnable, 40);
}
}
};
and finaly DoWork Method :-
private int doWork() {
// TODO Auto-generated method stub
Timer t=new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
mProgressStatus=mProgressStatus+1;
}
}, 1000);
time=mProgressStatus;
return mProgressStatus;
}