You can use the following code in the overridden onStop method of your activity:
@Override protected void onStop(){ super.onStop(); Intent intent = new Intent(this, ClassNameOfYourActivity.class); startActivity(intent); }
The problem with beauty: your activity will reappear if any other activity tries to attract attention. So this is not a modal window.
And it is dangerous! You cannot process the Android GUI; you can only control the graphical interface of your application. For example, turning on debugging mode in the off state, an application for destruction (only by ADB), achieving system settings, etc. It will be impossible. If you disable ADB and combine it with an auto-start mechanism, you will fall into the trap.
So, you will not be popular if you share it with Play :)
bdevay
source share