I'm trying to display programmatically an AlertDialog from the Application class using the applicationContext. I'm using my own Theme that extends Theme.Material3.Light. Only Toast messages works fine. I'm getting this error:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
My application Theme is:
android:theme="@style/Theme.MyTheme"
MyTheme is defined as:
<style name="Theme.MyTheme" parent="Theme.Material3.Light">
I have also a custom style for AlertDialogs defined in MyTheme:
<!-- AlertDialog Style-->
<style name="AlertDialogTheme" parent="MaterialAlertDialog.Material3">
<item name="android:background">@drawable/dialog_light</item>
</style>
The class from which I launch the event
class AppController: Application()
I tried changing the default theme in the Manifest and then setting the custom one programmatically when the application in launched but it did not work.