Returning this question from the dead who want to help someone with the same problem somewhere in time,
Recently, I ran into a much deeper, but similar problem: I had to display the presentation anywhere in the system (I work with the built-in android), and any application can be used on the main screen.
At first, I thought about creating a service that controlled the presentation of the presentation and was initialized when the application started. But the problem was that I could not show the presentation, because, as you remember, it inherits from the dialog and the same problem that occurs when you call getApplicationContext () when creating the dialog.
My solution was: There is WindowManager.LayoutParam called TYPE_SYSTEM_ALERT , which is used to display alerts, such as the Low Battery Alert Dialog. Using this property, you can create a dialog from a service and display it correctly, and since the Presentation class is a child of the dialog box, just setting this property makes it work.
The magic happens here:
WindowManager.LayoutParams l = mPresentation.getWindow() .getAttributes(); l.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; mPresentation.show();
Remember that in order to achieve this, your XML application must have SYSTEM_ALERT_WINDOW permission.
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
I think this should also solve your problem, but it is a little complicated and you need proper treatment to stop the presentation as soon as you need.
source share