There are 2 problems with the solution of marc1s, 1. it does not look very good, and you cannot change its appearance and filling, for example. text font or color etc. 2. any other application can replace it
Therefore, it is better if you show the view using the window manager from the service. That way you can show any view you want to show.
eg. my code is below in onStartCommand my service
WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); View mView = mInflater.inflate(R.layout.score, null); WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON , PixelFormat.RGBA_8888); mWindowManager.addView(mView, mLayoutParams);
Shirish herwade
source share