User dialogue or dialog thematic activity

I see that many developers choose the theme of their activity as a dialogue, and do not use the android dialogue and configure it.

I searched the Internet for this answer, but could not find it.

Can someone give me a pro and con method of topic activity? Of course, this gives you more freedom, but are there any stylistic reasons to avoid setting up a standard dialog?

I myself needed to reuse fragments in the dialogs, so I created a thematic activity to satisfy my needs, but now I am having problems getting results from a thematic activity.

Thanks in advance. Bram

+4
source share
2 answers

1) Start your activity using startActivityForResult.
2) Before closing your activity in the dialog mode, add the necessary data to the target add-ons and save them using SetResult (int, intent).
3) To process the results, add code to the actActivityResult of the parent activity, which will retrieve data from the stored intent.

no problems.

Yes, if you need to add heavy user logic to your "dialog", it is preferable to use stylized activity. In case of simple warnings - use Dialog.

+1
source

A user dialog is easier to create (you don't need to handle onCreate, onPause, screen rotation, ...) and have less overhead.

Therefore, you should use a custom dialog when you do not want to display something more complex than a dialog.

+1
source

Source: https://habr.com/ru/post/1387197/


All Articles