0

How to display custom dialog on Android home screen ? First Create BroadcastReceiver()

Second Create CustomDialog As Activity

add to manifest

<activity android:name=".view.activity.CustomDialog"
        android:launchMode="singleInstance"
        android:screenOrientation="fullSensor"
        android:theme="@style/AlertDialogTheme"
        />

add Style AlertDialogTheme to style.xml

<style name="AlertDialogTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert.Bridge">

</style>

Third Move by Intent to CustomDilog() Activity

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Ali Al Fayed
  • 495
  • 1
  • 5
  • 13
  • It's unclear what problem you're trying to solve here. To enable others to help you, describe the exact behavior you expected, as well as how that behavior differs from what is happening with your current implementation. Include the exact text of any error messages, (including, for any exceptions, the full [stack trace](https://stackoverflow.com/a/23353174) and which line of code is producing it). Please see [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Ryan M Apr 03 '20 at 23:16
  • This appears to be an answer written as a question. You can always answer your own question, but please do so as an answer, not in the question. – Ryan M Mar 25 '21 at 10:35

1 Answers1

1

If you need show dialog on android home screen. You need to set windows type for that dialog: Example:

val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
        } else {
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
        }
dialog?.window?.setType(type )

Hope this help!

Chuong Le Van
  • 274
  • 1
  • 8