I Found some codes for quit an Android application programatically. By calling any one of the following code in onDestroy() will it quit application entirely?
To exit you application you can use the following:
getActivity().finish();
Process.killProcess(Process.myPid());
System.exit(1);
Also to stop the services too call the following method:
private void stopServices() {
final ActivityManager activityManager = SystemServices.getActivityManager(context);
final List runningServices = activityManager.getRunningServices(Integer.MAX_VALUE);
final int pid = Process.myPid();
for (ActivityManager.RunningServiceInfo serviceInfo : runningServices) {
if (serviceInfo.pid == pid && !SenderService.class.getName().equals(serviceInfo.service.getClassName())) {
try {
final Intent intent = new Intent();
intent.setComponent(serviceInfo.service);
context.stopService(intent);
} catch (SecurityException e) {
// handle exception
}
}
}
}