1. Download our Official Android App: Forums for Android!

Apps how to move to another activity in android application

Discussion in 'Android Development' started by ritusingh, Dec 16, 2009.

  1. ritusingh

    ritusingh Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Dec 11, 2009

    Dec 11, 2009
    2
    0
    5
    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Dec 17, 2009

    Dec 17, 2009
    2
    0
    5
    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...