Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The proper way to do this requires a few steps. Sorry, it's not trivial if you haven't done it before:</p> <p>First, you're going to use Android's built-in <code>AlarmManager</code> to schedule the time you want your app to be activated. You schedule a new alarm with the time to wake up and a <code>PendingIntent</code>.</p> <p>Second, create your <code>PendingIntent</code> that's used to activate your app for the time to show the alarm. </p> <p>Third, you can handle this Intent several ways, the most common is to create a class that extends <code>BroadcastReceiver</code> to receive the Intent. This class is notified when it's time to show the alarm. The Intent that you created and put inside your PendingIntent is passed to its <code>onReceive()</code> method. You pass this information to your app to display the alert dialog. --- You can alternatively just register your main app to receive the Intent instead, then override the <code>onNewIntent(Intent)</code> method in your Activity.</p> <p>Four, register your <code>BroadcastReceiver</code> in your <code>AndroidManifest.xml</code> file. This is also the place to register this receiver to listen for the Intent you created. You do this using the <code>&lt;intent-filter&gt;</code> tag. </p> <p>Five, (optional) if you want your alarm to display even if the phone is asleep, and you want to make sure it doesn't go back to sleep before the user acknowledges the alarm, you'll need to obtain a WAKE_LOCK to do so.</p> <p>The reason this is preferable to using a Service is it doesn't consume resources just to wait for the alarm, and also it still works if Android decides to kill your app free up memory. Good luck and happy coding!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload