Is it possible to run Unity build as an Android Service?

I want to draw some 3D objects on a transparent background to be seen over the running applications.
I intent to make it as a Android Native Service with OVERLAY_PERMISSION.
and add UnityPlayer into floating windows via WindowManager.addView()

Is it possible to run my game built with Unity as an Android Service?

Hi there,
Yes, You should be able to develop an Android app and use Unity as am embedded Library, see here for more details.

Thank @MartinTilo
But I want to draw Unity 3D objects on Android Native Service that will be seen over the running applications.

I tried but it can only display black screen.

Here is my sample source:

LayoutInflater layoutInflater = LayoutInflater.from(this);
newView = (ViewGroup) layoutInflater.inflate(R.layout.service_layout, null);

ViewGroup unityLayout = (ViewGroup)newView.findViewById(;

unityLayout.addView(unityPlayer, new ViewGroup.LayoutParams(-1, -1));

//when starting service, I add unity as a floating window
public int onStartCommand(...){
    windowManager = (WindowManager)getApplicationContext()

   WindowManager.LayoutParams params = new WindowManager.LayoutParams (

   windowManager.addView(newView, params);‚Äč


The issue of transparently drawing over the OS is discussed here. Though you might have to set this option via this API.

hi , have you solved this problem, i also need to do this. i haved successed in unity 2017, but not in higher version

useful topic :+1: