Android gets alarm information for third-party alarms

Source: Internet
Author: User


Alarm Information Acquisition

Alarm time, Alarm note information

The point at which the alarm causes system changes:

1. Send Notification

2. Play Ring

Alarm information structure

clockinfo{

String Apkname;

String StartTime;

String backup;

Boolean isplayingring;

}

SendNotification

Systemui

Basestatusbar.java

Parse the Expandedview to get the notification that is sent by clock. Because notification is displayed in Basestatusbar, it is not possible to confirm that the ringtone is playing, so isplaying= False. The captured clock information is sent to the server via broadcast.

Alarm information: {

Apkname;

starttime=****;

backup=****;

Isplayingring=false;

}

Play Ring

MediaPlayer

Mediaplayer.java

When clock is generated, the Mediaplayer.start () method is called to play the ringtone. In the call to start () method, create the Clockinfo and send it to the server via broadcast.

Alarm Information {

apkname=**;

starttime=****;

Backup=empty;

Isplayingring=true;

}

Why do I need to create a clockinfo in two places?

1. On-the-clock alarm can be set without sending notification. You can only get to it by calling the Mediaplayer.start () method.

2. Calling the Mediaplayer.start () method does not get the contents of the notification. In order to get the backup information of clock, we need to get clockinfo in StatusBar.

3. On-time alarms and instant alerts will show the next alarm in StatusBar, which is not an alarm event. Therefore, it is necessary to judge the alarm information produced by Mediaplayer.start () at the same time.

Store results

After receiving the broadcast of clock information, the server parses the clock information inside and stores it in the local database.

Media start

Apkname =**, starttime=***,backup=, isplayingring=true;

StatusBar

apkname=**, starttime=***, Backup=****,isplayingring=false;

When storing the clockinfo sent by StatusBar, it is determined that:

Whether there is apkname=** and Backup=empty andisplayingring=true in a certain time interval;

If there is

Update the backup content that already exists.

When storing clockinfo sent by media, it is determined that:

Whether there is apkname=** and backup!=empty andisplayingring=false within a certain time interval;

If there is a setup isplaying=true;

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.