Mithilesh Kumar Mithilesh Kumar - 3 months ago 16
Android Question

I am not able to finish/close my application

I have used Open Finish Activity using intent here :

Intent i = new Intent(yourScreen.this,Finish.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);


Then I have used.

public class Finish extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.runFinalizersOnExit(true); // 1)Option
System.exit(0); // 2)Option
finish(); // 3)Option
android.os.Process.killProcess(android.os.Process.myPid()); //4)last
}}


I have try all options

here my Application gone in background.
when i click my hardware apps menu button then its appear in list.

Answer

Could you try it for us, please? :D

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
     finishAndRemoveTask();
} else {
     finish();
}
Comments