Widget cannot update issue modification after Android clears data

Source: Internet
Author: User

When the data is purged, action_package_data_cleared broadcasts are sent, and the broadcast is monitored and processed in the Widgetprovider.


 public static class Packagedataclearedreceiver extends Broadcastreceiver {private static final String Action_pack        age_data_cleared = "Com.mediatek.intent.action.SETTINGS_PACKAGE_DATA_CLEARED"; public void OnReceive (context context, Intent Intent) {if (!            Action_package_data_cleared.equals (Intent.getaction ())) {return;            } String pkgname = Intent.getstringextra ("PackageName");            MUSICLOGUTILS.V (TAG, "packagedataclearedreceiver recevied pkgname =" + Pkgname); if (pkgname! = null && pkgname.equals (Context.getpackagename ())) {Mediaappwidgetprovider MEDIAAPPW                Idgetprovider = Mediaappwidgetprovider. getinstance ();                    if (Mediaappwidgetprovider = = null) {MUSICLOGUTILS.V (TAG, "Mediaappwidgetprovider is null");                Return            } mediaappwidgetprovider.defaultappwidget (context, NULL); }        }    } 

The Defaultappwidget () function reloads the widget information and layout files so that the default values can be restored.
Finally, don't forget to add the androidmanefest.xml inside:

        <receiver android:name= "Com.android.music.mediaappwidgetprovider$packagedataclearedreceiver" >            < intent-filter>                <action android:name= "Com.mediatek.intent.action.SETTINGS_PACKAGE_DATA_CLEARED"/>                <category android:name= "Android.intent.category.DEFAULT"/>            </intent-filter>        </ Receiver>


Widget cannot update issue modification after Android clears data

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.