androidprocessddmskill-process

Is it possible for an Android app to kill its own process


Is it possible for an Android app to kill its own process? Say, as an anti-tampering feature, the app detects that its integrity has been breached, say by checking the app signer cert. It then exits the app, but the app process still lingers in memory. If an attacker had changed AndroidManifest.xml to set android:debuggable="true", he could still view it in Android Device Monitor and debug/analyze the app if the process still exists.


Solution

  • you can kill process by using this code

    This will kill the process, but it won't necessarily kill the task in memory. So when the app is restarted, the activity stack (task) will just get re-created from last time Please use this code in Main Activity (Please don't use in every activities or sub Activities):

     @Override
      public void onBackPressed() {
    
    android.os.Process.killProcess(android.os.Process.myPid());
    // This above line close correctly
    }