Android obtains the alarm information of a third-party alarm.

Source: Internet
Author: User


Alarm information collection

Alert time and alert remarks

System changes caused by an alarm:

1. Send Notification

2. Play Ring

Alert Message structure

ClockInfo {

String apkName;

String startTime;

String backup;

Boolean isPlayingRing;

}

SendNotification

SystemUI

BaseStatusBar. java

Parse ExpandedView to get the Notification sent by Clock. Because the Notification is not displayed in BaseStatusBar, isPlaying = false. The retrieved Clock information is broadcast to the server.

Alert Message :{

ApkName;

StartTime = ****;

Backup = ****;

IsPlayingRing = false;

}

Play Ring

MediaPlayer

MediaPlayer. java

When a Clock is generated, the MediaPlayer. start () method is called to play the ringtone. In the start () method, create ClockInfo and send it to the server through broadcast.

Alert Message {

ApkName = **;

StartTime = ****;

Backup = Empty;

IsPlayingRing = true;

}

Why do we need to create ClockInfo in two places?

1. You can set the Enable alarm to not send notifications. At this time, you can only obtain it and call the MediaPlayer. start () method.

2. The content of Notification cannot be obtained by calling the MediaPlayer. start () method. In order to obtain Clock backUp information as much as possible, you need to get ClockInfo in StatusBar at the same time.

3. The next alarm is displayed in the StatusBar when the alarm is triggered. Therefore, you must determine the alert information generated by MediaPlayer. start.

Storage results

After receiving the broadcast that collects Clock information, the server parses the clock information and stores it in the Local database.

Media start

ApkName = **, startTime = ***, backup =, isPlayingRing = true;

StatusBar

ApkName = **, startTime = ***, backup = ***, isPlayingRing = false;

When the ClockInfo message sent by StatusBar is stored, it determines:

Whether apkName = ** and backup = Empty andisPlayingRing = true exists in a certain interval;

If yes

Update existing backup content.

When the ClockInfo sent by Media is stored, it determines:

Whether apkName = ** and backup exists in a certain interval! = Empty andisPlayingRing = false;

If isPlaying = true exists;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.