Skip to content Skip to sidebar Skip to footer

How To Make A Sington Dialog

In android app, having a few activities with multiple fragments. Those activities or fragment could be running alive even if it's not on the top of the backStack, and receiving not

Solution 1:

You can't make Dialog singletone, because Dialogs are linked with current view. And your current view may change - dialog may be sown from different instances of the activities (one or many).

But you can implement a simple singletone class to store all dialog data - save data into onPause and retrieve it in Dialog's onCreateView.

So you will get singleton instance with all data, but Dialogs may vary according to current view.

Also you can store a weak link to the shown dialog in that singletone class. Using such method, you can detect is your dialog currently shown or not.

Post a Comment for "How To Make A Sington Dialog"