how to move to another activity in android application


Last Updated:

  1. ritusingh

    ritusingh New Member This Topic's Starter

    Joined:
    Dec 11, 2009
    Messages:
    2
    Likes Received:
    0
    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
     

    Advertisement
  2. victoria122

    victoria122 New Member

    Joined:
    Dec 17, 2009
    Messages:
    2
    Likes Received:
    0
    Code (Text):
    1. 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 (Text):
    1.  
    2. startActivity(i);
    3. finish();
    4.  
    If you need a result from the subactivity and need to go back to the parent activity:
    Code (Text):
    1.  
    2. startActivityForResult(i, number);
    3.  
    And you will need to add method:
    Code (Text):
    1.  
    2. protected void onActivityResult(int requestCode, int resultCode, Intent data)
    3.  
     

Share This Page

Loading...