Activity to Simulate

I mean to create a simple activity to simulate the progressbar we have created. please take a look at full code below:

1. Declare variables needed for simulation:

private ARProgressBar ap;
private static final int PROGRESS = 0xDEADBEEF;
protected int mProgress;
protected boolean mCancelled;

2. Fill code at onCreate() on Activity class:

public void onCreate(Bundle icicle)

ap = (ARProgressBar) this.findViewById(;
mCancelled = false;
Button b = (Button) this.findViewById(; 
b.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
mCancelled = false;
Button bStop= (Button) this.findViewById(;
bStop.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
mCancelled = true;


3. Create mHandler variabel as a Handler Message

protected Handler mHandler = new Handler() {

public void handleMessage(Message msg) {
if ((msg.what == PROGRESS) && (!mCancelled)) {
mProgress += 50;
if (mProgress > 10000) {
mProgress = 0; 
sendMessageDelayed(obtainMessage(PROGRESS), 50);


4. Compile and push to the emulator and run you will have your progress bar running by clicking Simulate Button, and stop it by clicking Stop button.

Was This Information Help ?