I've been trying to figure out how to draw an activity over the current running app. My app consists of a service running in the background. It will wait till a certain apps opens and then it needs to draw the alert over the current running app. Someone told me about a floating activity but I can't get too much information on that. This is what I want to archieve.
Asked
Active
Viewed 54 times
1 Answers
0
Firstly, I suggest you take a look of this offical documentation
https://developer.android.com/reference/android/Manifest.permission.html#SYSTEM_ALERT_WINDOW
I don't think you would be relying on an activity to achieve this "floating" result similar to the Facebook chat head.
This is a answer that you should see although it's working with pure Java.
What APIs in Android is Facebook using to create Chat Heads?
This code is written in Java, the partial translation is shown below. thanks @Cheesebaron
var windowManager = GetSystemService(WindowService).JavaCast<IWindowManager>();
var waitingImage = new ImageView (this);
waitingImage.SetImageResource (Resource.Drawable.Icon);
var param = new WindowManagerLayoutParams (
ViewGroup.LayoutParams.MatchParent,
ViewGroup.LayoutParams.MatchParent,
WindowManagerTypes.Phone,
WindowManagerFlags.Fullscreen,
Format.Translucent);
param.Gravity = GravityFlags.Top;
waitingImage.SetScaleType (ImageView.ScaleType.FitXy);
windowManager.AddView (waitingImage, param);

Community
- 1
- 1

Peter Zhong
- 86
- 1
- 7