user2638180
user2638180

Reputation: 1023

Keeping an active app always on top except for home screen

I want to know if there's some way to maintain an Android activity always on top regardless of any other apps present in the phone device that might put on top on it, except for home screen via home button, which cannot be helped.

I've checked that if a whatsapp popup displays over my activity, that activity starts showing a strange behavior.

Maybe this can be controlled by some events, but I think it's much easier to avoid anything that might put on top of app, so no strange behavior appears.

Is there any way to do that?

Upvotes: 0

Views: 5773

Answers (1)

Regulus
Regulus

Reputation: 387

It depends on the level of control that you have over the device. If your app is going to be publicly available you cannot (and should not) do much to prevent other components from coming on top of the stack.

Apart from that, one thing you can do is check for UI changes through this: https://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener or/and activity lifecycle events (like onPause) and prevent whatever this "strange behaviour" is.

The inverse way to deal with this is to prevent any app from having the "Draw Over Other Apps" permission, but as I said it depends on the environment of your deployment.

Upvotes: 1

Related Questions