Android Widget Widgets

Source: Internet
Author: User

1.<meta-data> provides a name value pair for the build

<meta-data android:name= "string"  
Android:resource= "Resource Specification" android:value= "string"/>

can be defined in <activity><activity-alias> <service><receiver > in

A component can contain any number of <meta-data>.

When parsing to the <meta-data> node, put the Bundle object and assign it to packageiteminfo.metadata

Activityinfo info = Getpackagemanager (). Getactivityinfo (new componentname (This, Myexcesizeactivity. class  == bundle.getstring ("Com.rytong");
<meta-data android:name= "Com.rytong" android:resource= "@string/liyuejiao" ></meta-data>

only get the ID of the @string/liyuejiao as com.rytong the value

2 defining Widgets (extends Appwidgetprovider)

When the Widget is added, deleted, according to <receive 's <action android:name= "xx", thesystem issues a broadcast ,

Its own definition of the broadcast recipient Mywidget (extends Appwidgetprovider) receives the broadcast, calls onenabled (), OnUpdate (), ondeleted (), Ondisabled ().

<receiver android:name= "Exampleappwidgetprovider" > <intent-filter> <action android:name= " Android.appwidget.action.APPWIDGET_UPDATE "/> <action android:name=" android.appwidget.action.APPWIDGET_ DELETED "/> </intent-filter> <meta-data android:name=" Android.appwidget.provider " android:resource< /c1>= "@xml/example_appwidget_info"/></receiver>

3 get the Widget's configuration file by <meta-data> android.appwidget.provider This fixed name ( Specify individual properties )

Res/xml/appwidget_info.xml

<appwidget-provider xmlns:android= "http://schemas.android.com/apk/res/android" android:minwidth= " 294DP " android:minheight=" 72DP " android:updateperiodmillis=" 86400000 " android:previewimage = "@drawable/preview" android:initiallayout= "@layout/example_appwidget" android:configure= "Com.example.android.ExampleAppWidgetConfigure" android:resizemode= "Horizontal|vertical" ></ Appwidget-provider>

**

Android:updateperiodmillis periodically sends broadcasts called "Android.appwidget.action.APPWIDGET_UPDATE" for broadcast recipients

android1.5 after 0, do not need to periodically send update broadcast

Android:initiallayout specifying the default display interface

4 Start a service, run in the background for a long time, keep updating widgets

Set as daemon: When the service thread exits, the daemon also exits

When there are multiple widgets on the desktop , each widget is deleted, calling ondeleted ()

When the last Widget is deleted, call ondeleted (), ondisabled ()

When there is no widget on the desktop, that is , when the last widget is deleted, the service is stopped in ondisabled () .

Android Widget Widgets

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.