How to close / stop the launch of the application on the background of Android

I want to close or stop starting the application when I exit the main screen, this means that the first time you click on the android button, the first application diagram appears on the screen. I use this, but my application is running in the background

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Splash screen view setContentView(R.layout.splash); } **public void onDestroy() { super.onDestroy(); System.runFinalizersOnExit(true); System.exit(0); }** 
+3
source share
2 answers

get the process id of your application and kill this onDestroy () method

 @Override public void onDestroy() { super.onDestroy(); int id= android.os.Process.myPid(); android.os.Process.killProcess(id); } 
+11
source

Try it,

  int pid = android.os.Process.myPid(); android.os.Process.killProcess(pid); 
+2
source

Source: https://habr.com/ru/post/906472/


All Articles