Recent whim, want to make up an Android battery plugin on the desktop, one is this app does have its practical value, the second is to build up the amount of work should not be very large, do not spend too long, three and can learn the development of the widget under the three-way, so, Pause the game development of learning, to make a widget first.
After the search and integration of multiple data finally realized, the effect is as follows:
Long Press the desktop blank, appear menu, click Widgets, at this time the plugin has been loaded:
When the power is connected, the robot will be surrounded by starlight, indicating that it is charging and that the surrounding starlight disappears when the charge is not charged.
The robot displays a percentage of the battery charge.
Click the robot icon to jump out of the battery information and click the screen again to close the details.
The implementation of the code is described below:
The entire project mainly realizes two parts, one is the appwidget part, realizes the desktop widget the display, the update and so on, another part is the display battery detailed information appears after clicking the widget realization.