ryru
ryru

Reputation: 61

Open dialog disappears after screen turns off

When my app has an open dialog e.g. dlg.show(); and the screen turns off by timeout the active and displayed dialog is disappeared after turning on the screen again. I'd like to have the dialog still preset.

Is there a good/recommended way to fix/workaround this behavior?

For a solution, I could imagine one of the following approaches, but could not find further information:

  1. Disabling screen timeout globally for the app.
  2. Disabling screen timeout for dialog specifically.
  3. Using another dialog type (modal, modeless or interaction) that keeps staying.

Maybe there are other ways to fix this?

Upvotes: 1

Views: 61

Answers (1)

James H
James H

Reputation: 1116

Use a variable that you store the state of in Preferences. Perhaps a Boolean so when the dialog shows it is true, and if someone exits the app you save it in preferences (you can use exit form action or add something to the lifecycle methods). When the app restarts, get the state from Preferences and display the dialog again if the variable is true.

You could use and integer or string if there are multiple possible dialogs that you might need to show.

Upvotes: 2

Related Questions