Development and implementation of the Android Widget battery plug-in

Source: Internet
Author: User

 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.

Related Article

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.