-1

I want to close Android application programatically through code.I have 2 activities.First MainScreen & the Second Screen.

I tried the code

System.exit();
finishAffinity();
finishAndRemoveTask();

Problem is this its getting me to the HomeScreen

Thanks

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Tushar
  • 5,907
  • 15
  • 49
  • 81

2 Answers2

1

Try with this,

System.exit(0);

this.finishAffinity(); this option is for above api 16

Jayamurugan
  • 542
  • 2
  • 10
0

Can you try using

`android.os.Process.killProcess(android.os.Process.myPid());`

in your onDestroy() of Main activity. For reference go through this

Community
  • 1
  • 1
Nivedh
  • 971
  • 1
  • 8
  • 19