Analysis of principle and implementation method of low battery alarm prompt developed by Android 4.4

This paper describes the principle and implementation method of Android 4.4 battery low battery alarm. Share with you for your reference, as follows:

In previous versions, the battery power was low by sending intent action_ BATTERY_ Low, and in Android 4.4, by sending intent action_ BATTERY_ Changed, that is, as long as the battery power changes, check whether a low battery alarm is required, and the implementation is moved to the powerui.

route:

frameworks/base/packages/systemUI/src/com/android/systemUI/power/PowerUI.java

When the battery level changes, the batteryservice sends an action_ BATTERY_ Changed intent

Then the following functions will be called:

If you don't want to display the low battery dialog box, just don't call showlowbatterywarning().

The problem I encountered is that after the charging stand is plugged in, the power on still displays a low battery alarm, prompting to plug in the charger. The reason for this problem is that the battery is supplied by another board, so there is no plug-in information, and the battery status is also battery by default_ STATUS_ UNKNowN。

So just change the status to battery_ STATUS_ Charging can fix this problem ~

More readers interested in Android related content can view the special topics of this site: summary of Android hardware related operation and application, summary of Android file operation skills, introduction and advanced tutorial of Android development, summary of Android resource operation skills, summary of Android view skills and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>