I have 4 activities: changeView, changeViewTwo, NoRunning, YesRunning. Also, I have 2 XML: yes_running and no_running
The first screen (no_running), has a button that changes the view like this:
Button buttonchange01 = (Button) findViewById(R.id.Button01);
buttonchange01.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.example.runningtimer.changeView"));
}
});
on the manifest
<activity
android:name="changeView"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.runningtimer.changeView" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
on the changeView.java
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.yes_running);
}
that is done correctly, however, when the new one is on view, I have a progressbar that counts to 10 and it should go back to no_running.xml but it doesnt, this is how YesRunning activity looks like
public class YesRunningActivity extends Activity {
ProgressBar myProgressBar;
int myProgress = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yes_running);
myProgressBar=(ProgressBar)findViewById(R.id.progressbar_Horizontal);
new Thread(myThread).start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.no_running, menu);
return true;
}
public Runnable myThread = new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
while (myProgress<100){
try{
myHandle.sendMessage(myHandle.obtainMessage());
Thread.sleep(100);
}
catch(Throwable t){ }
}
if (myProgress==100){
finish();
startActivity(new Intent("com.example.runningtimer.changeViewTwo"));
myProgress = 0;
}
}
Handler myHandle = new Handler(){
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
myProgress++;
myProgressBar.setProgress(myProgress);
}
};
};
}
manifest for changeViewTwo
<activity
android:name="changeViewTwo"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.runningtimer.changeViewTwo" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
changeViewTwo
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.no_running);
}
Any idea why it is not going back? or how can I make it go back?