• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps how to move to another activity in android application

ritusingh

Lurker
Hi Frens...

Can anyone please tell me that how to move from one activity to another using the class intent.
i have followed the code:-

Intent intent=new Intent();
in.setClass(this.MainActivity,subactivity.class);
startActivity(intent);

this code is not working .
what changes should i made so that i can able to execute my program?
pls help me out.

Thanx-
Ritu Singh
 
Code:
Intent i = new Intent(this,subactivity.class);
If you do not want a response and are simply moving to the next screen without needing to go back:
Code:
startActivity(i);
finish();
If you need a result from the subactivity and need to go back to the parent activity:
Code:
startActivityForResult(i, number);
And you will need to add method:
Code:
protected void onActivityResult(int requestCode, int resultCode, Intent data)
 
Back
Top Bottom