How to make the activity window always on top

I want to create an activity that always stays on top (for example, modal windows or task manager in Windows) of other actions. How can I do this on Android? Thanks

+6
android android-activity window always-on-top
source share
3 answers

You can not. As defined in the Android system.

+5
source share

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 :)

+10
source share

Depending on what you are trying to do, you may be pleased with windows that remain on top of other actions.

Applications such as the Super Video client and floating notes can display floating windows over other actions. These questions may point you in the right direction:

  • Creating a system overlay window (always on top)
  • How to create continuous fullscreen overlay activity in Android .
+3
source share

All Articles