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)