orip
orip

Reputation: 75477

Delayed execution in an Android activity

I would like to trigger showing a dialog X seconds after something happens in an activity (resumed, button clicked, etc.)

Upvotes: 0

Views: 2558

Answers (2)

orip
orip

Reputation: 75477

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.

Upvotes: 0

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29131

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.

Upvotes: 3

Related Questions