How To Kill A Process?
Solution 1:
You can try this.finish()
The other choices kill the process without informing the android system, which assumes something the user wanted to do has crashed and restarts it.
But your assumptions about closing the activity preventing data leakage is mistaken. If you want to provide a log out button, do that and have it negate whatever access tokens/keys were being used to obtain access.
Also think about what happens if some other activity comes to the foreground without the user exiting yours - for example, what if they receive a phone call?
Solution 2:
Just my idea, After you start the second activity (this line),
startActivity(new Intent(FirstActivity.this,SecondActivity.class));
You can kill the first activity. Through,
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
so, now first activity didn't come.
Another way,
You can get first Activity's process id and send the process id to second activity, through bundle.
First kill the First Activity Process, next You can kill the second Activity process.
so, now first activity didn't come.
Solution 3:
i had got that problem while i am newer in Android. i had created two activity and switch from one layout to anther layout but when i kill process of second activity, first activity will be resume(); and first layout will shown in display.
answer of your question is : in first activity resume you have to call finish(); method on in onResume() method.
Solution 4:
System.exit(0); by use of this all current process will be kill
Post a Comment for "How To Kill A Process?"