startActivityForResult ??????


  1. aryaxt

    aryaxt Member

    I open a new activity by calling startActivityForResult.
    Inside my SecondActivity class i have an exit button, when the user clicks it i need to close the SecondActivity.
    What method should i call to close SecondActivity?
    I tried calling finish() and finishActivity() on my exitButtonClicked, but it didn't do anything.
    Code (Text):
    1. public class FirstActivity extends Activity {
    2.      public void onCreate(Bundle savedInstanceState) {
    3.      .......
    4.      .......
    5.      Intent i = new Intent(this , SecondActivity.class);
    6.      this.startActivityForResult(i, 1);
    7.      }
    8. }
    Code (Text):
    1. public class SecondActivity extends Activity {
    2.      private void exitButtonClicked()
    3.      {
    4.           //I need to call a method to close this activity
    5.      }
    6. }
    7.  

    Advertisement
    :
  2. IanGClifton

    IanGClifton Well-Known Member

    You want to do something like

    setResult(RESULT_OK, result);
    finish();

    or

    setResult(RESULT_CANCELED, null);
    finish();
    aryaxt likes this.
  3. aryaxt

    aryaxt Member

    thanks setting the result solved the problem
Loading...

Share This Page