Delayed execution in an Android activity
-
11-02-2021 - |
Solution
use handler.postDelayed(runnable, delayedms);
this is one of the methods, you can also use AlaramManager.
For AlaramManager your activity need not be active. and handler it should be.
OTHER TIPS
One option I considered: instead of attaching a dialog to an existing view, I can create a transparent view (with <activity android:theme="@android:style/Theme.Translucent.NoTitleBar"
as mentioned here) and have it create a dialog.
This is nice since I can create this activity with a delayed intent.
I need to make sure to call finish()
when the dialog is closed.
I'm not sure how to have this happen only if the original activity is still active.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow