How to make an activity window stay always on top
You can't. As this is defined in the Android system.
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);
}
Beauty problem: your activity will pop-up again if any other activity trying to claim the focus. So it's not a modal window.
And it's dangerous! You wont be able to handle the Android GUI, you'll be able to control only your application GUI. For instance, switching debug mode on-off, killing application (only over ADB), reaching system settings, etc. will be impossible. If you switch off the ADB and combine it with the auto start mechanism then you'll be in trap.
So you won't be popular if you share it with Play :)
Depending on what exactly you are trying to do, you might be happy with windows that stay on top of other Activities.
Apps like Super Video client & Floating Notes are able to display floating windows above other activities. These questions might point you in the right direction:
- Creating a system overlay window (always on top)
- How to create always-top fullscreen overlay activity in Android