Creating a Don't Ask Again style dialog
Create your dialog
To create your "Don't Ask Again" style dialog you will extend the class DontAskPopupScreen. This class will accept a UID through the constructor which is used for tracking the "Don't Ask" state automatically. The default state will be "Always Ask Again." Selecting the checkbox telling the application to stop asking will put it in the "Never Ask" state.
By default selecting the checkbox and hitting cancel will not alter the current state. To change this so the state is always changed depending on the checkbox, you can call setPersistOnCancel(true) from your subclass constructor.
Your subclass will look something like:
public class DataServiceNotification extends DontAskPopupScreen { private static final String MESSAGE = "Data service charges may apply when streaming videos. Continue to video?"; public DataServiceNotification() { super( UID.DATA_SERVICE_CONFIRMATION ); } protected String getMessage() { return MESSAGE; } protected void action() { // do something } }
When to call the dialog
The DontAskPopupScreen will automatically handle bypassing the confirmation depending on the persisted state. If the state was previously set to "Never Ask" and the dialog is opened again, it will bypass being displayed and go directly to calling DontAskPopupScreen.action().
