I had wandered in the web for an hour and hour, I couldn't able find a code that closes my app completely and closes all activities then return to home screen.Even though "EXIT' button is indispensable for an android app I couldn't find a perfect code for my job.I giving the codes didn't work.So please don't suggest that.
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
this code closes app and shows homescreen.But it didn't close running app.It simply minimises the app
Activity.finish();
System.exit(0);
protected void quit(){
Process.killProcess(Process.myPid());
}
This code simply restarts the current activity