In my app I have three activity as
-
Activity 1
-
Activity 2
-
Activity 3
How to switch between activities.
So how can this be done?
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.settingOpt:
Intent intent = new Intent(this, SettingsForm.class);
this.startActivity(intent);
this.finish();
break;
case R.id.reminderOpt:
Intent intentR = new Intent(this, ReminderForm.class);
this.startActivity(intentR);
break;
case R.id.helpOpt:
Intent intentH = new Intent(this, HelpForm.class);
this.startActivity(intentH);
this.finish();
break;
case R.id.shareOpt:
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_SUBJECT, "Name of the thing to share");
share.putExtra(Intent.EXTRA_TEXT, "www.gmail.com");
startActivity(Intent.createChooser(share, "Share LoveCycle's website link with your friends"));
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
Use following method on back button press event in Activity3:
And in Activity2 capture that setResult as follows and close this Activity:
Then you will get directly to Activity1.