Saturday, July 20, 2019

Working with support library AlertDialog in Robolectric

Robolectric provides a ShadowAlertDialog class with a getLatestAlertDialog function to get the last Android AlertDialog. However, in my project that uses a support library (AndroidX), that function returned null. To get the last shown dialog, I had to use ShadowDialog.getLatestDialog and cast that Dialog to the AlertDialog type from the support library.

No comments:

Post a Comment