Search code examples
androidandroid-alarms

Where Does the PendingIntent in AlarmManager.AlarmClockInfo Get Used?


The constructor to AlarmManager.AlarmClockInfo takes a PendingIntent, described as "an intent that can be used to show or edit details of the alarm clock". Where is this used by the system? I don't see anything in the Android 6.0 UI that would seem to trigger that PendingIntent.


Solution

  • The PendingIntent is returned by getShowIntent() in AlarmManager.AlarmClockInfo:

    public PendingIntent getShowIntent() {
        return mShowIntent;
    }
    

    and it's used in the onClick() method of StatusBarHeaderView:

    PendingIntent showIntent = mNextAlarm.getShowIntent();
    if (showIntent != null && showIntent.isActivity()) {
        mActivityStarter.startActivity(showIntent.getIntent(), true /* dismissShade */);
    }
    

    Visually, the thing the user clicks on to invoke the PendingIntent is the date/time of the alarm, shown in the following screenshot in grey to the right of the alarm clock icon:

    Android 6.0 Notification Shade, Showing Pending Alarm Clock