Recently, I was wondering how to compile an Android battery plug-in on the desktop. First, this App has practical value, and second, the compilation workload should not be very large, you don't have to spend too much time learning the development method of widgets, so you can do it three times. So you can pause the learning of Game Development and compile a Widget first.
After finding and combining multiple sources of data, we finally achieved the following:
Long press the blank area on the desktop, and a menu appears. Click Widgets. The plug-in has been loaded:
When the power is connected, the robot will be shining around, indicating that it is being charged. When it is not charged, the surrounding stars will disappear.
The robot shows the percentage of battery power.
Click the robot icon. The battery information is displayed. Click the screen again to close the details.
The following describes how to implement the Code:
The whole project mainly implements two parts: one is the AppWidget part, which enables display and update of desktop widgets, and the other is the Activity that displays the battery details after clicking the Widget.