[Anroid widget] highlights

Source: Internet
Author: User

1. updateperiodmillis is not executed

 
<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>

WhereAndroid: updateperiodmillis sets the update frequency in milliseconds. In actual use, I tested it with 1000 and found that it was not executed.

Public int updateperiodmillissince: API level 3how often, in milliseconds, that this appwidget wants to be updated. the appwidget manager may place a limit on how often a appwidget is updated. this field corresponds to the Android: updateperiodmillis attribute in the appwidget meta-data file.Note: updates requested with updateperiodmillis will not be delivered more than once every 30 minutes.

I checked the official documentation and found out that it would take more than 30 minutes. If you want to execute the task at a frequency of less than 30 minutes or allow the user to define it, we recommend that you use alarmmanager.Android: updateperiodmillis is set to 0.

2. In the android4.0 system, onenabled and ondisabled are not executed.

Onenabled: called when the first component is created

Ondisabled: called when the last component is deleted

Tests were performed on platforms 2.1, 2.2, 2.3, 2.3.3, 4.0.4. on platforms 4.0.4, creating the first build will not be called.Onenabled. deleting the last component will not be called.Ondisabled, only onupdate is called; other platforms are normal!


3. By the way, you can set the widget preview image (more than 3.0 ):

 
<Appwidget-provider xmlns: Android = "http://schemas.android.com/apk/res/android"... Android: previewimage = "@ drawable/preview"> </appwidget-provider>

Property list comparison:

(2.1)(4.0)

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.