Mastering Android Dialogs: Don’t follow official Google Guides

Patryk Kosieradzki
CodeX
Published in
12 min readNov 6, 2022

Photo by Randy Laybourne on Unsplash

This article is part of a multi-series on Mastering Android Dialogs

  1. Don’t follow official Google Guides
  2. Using Coroutines to show and get results from Dialogs easily
    COMING SOON

Intro

Callbacks, listeners, onActivityResults — these are spread all over Android APIs, and frankly speaking, it drives me crazy. Every time you want to ask for permission, take a picture, choose a file, or even show a simple dialog you have to deal with them. After some time I feel more like playing ping-pong in Android than actually writing readable, maintainable, and, what’s very important, REUSABLE code.

Do we have to use them? Is there a better way? Of course, there are lots of better ways and countless solutions to the same problem — as usual in Android. This article explains why Google Guides for Dialogs are bad and what risks you and your apps may face if you follow them.

What is currently recommended by Google?

Let’s look into the official documentation as of November 2022 and check out what Google recommends when dealing with dialogs. The most common places to find information about it are the guides below.

The guides are not very long, to be honest. They are very deficient. I could imagine someone who’s just started learning Android and wants to get into Dialogs, but he only finds a few simple examples, not fitting into most real-world apps. Unfortunately, that’s the case for most guides and samples.

Let’s go over these guides and recommendations 👇

Showing a Dialog

Patryk Kosieradzki
CodeX
Writer for

Senior Android Engineer @ Moss, Podcaster @ AndroidTalks, based in Warsaw, Poland