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

Apps startActivityForResult ??????

aryaxt

Newbie
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:
public class FirstActivity extends Activity {
     public void onCreate(Bundle savedInstanceState) {
     .......
     .......
     Intent i = new Intent(this , SecondActivity.class);
     this.startActivityForResult(i, 1);
     }
}
Code:
public class SecondActivity extends Activity {
     private void exitButtonClicked()
     {
          //I need to call a method to close this activity
     }
}
 
You want to do something like

setResult(RESULT_OK, result);
finish();

or

setResult(RESULT_CANCELED, null);
finish();
 
Back
Top Bottom