1

I have to exit from application when user is some in middle of application. I have use finish() and System.exit(0) method but it only exits current activity. If any one know about this please let me know.

Thank You

Vikram

Vikram
  • 1,072
  • 2
  • 20
  • 33

2 Answers2

1

if you are calling activity B from an activity A.and C from B

A->B

use startactivityforresult from A

and again B->C

use startactivityforresult from B

and when you want to exit from C then setResult(i.e. RESULT_OK) and finish C.and in OnActivityResult() in B,check if resultcode == RESULT_OK then again finish B and setresult(RESULT_OK) for A.same procedure will follow to finish A.

this will exit you from the application.and application will start from A not from C.

ankita gahoi
  • 1,532
  • 2
  • 15
  • 28
0

try this (*Not tested):

@Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        this.finish();
    }

Also try to Spare some time to go through this discussion

Community
  • 1
  • 1
Harry Joy
  • 58,650
  • 30
  • 162
  • 207