How to show Dialog Box from the class which extends Application in android?

前端 未结 3 1671
谎友^
谎友^ 2020-12-17 10:21

I want show a dialog box after specific condition , but for demo right now I want show a Dialog Box from the class which extends Application . here is my code



        
3条回答
  •  长情又很酷
    2020-12-17 10:57

    The Application class is there to hold data that can be used by your activities, not to interact with the UI. Display the dialog from the activity you want it displayed in.

    EDIT: If you want to call the code from multiple activities, you can have a superclass for these activities, that contain the code with the dialog. Then extend this superclass in all the activities you want to display the dialog, and call it from there.

提交回复
热议问题