Add `data android:scheme="file"` to home widget -
i have home widget follow.
<receiver android:name="org.yccheok.gui.widgetmyappwidgetprovider" android:exported="true" > <intent-filter > <action android:name="android.intent.action.media_mounted" /> <data android:scheme="file"/> <action android:name="android.appwidget.action.appwidget_update" /> <action android:name="android.appwidget.action.appwidget_enabled" /> <action android:name="android.appwidget.action.appwidget_deleted" /> <action android:name="android.appwidget.action.appwidget_disabled" /> <action android:name="android.appwidget.action.appwidget_options_changed" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info" /> </receiver>
i wish widget able refresh itself, when external drive available after device restarting. hence, that's why add
<data android:scheme="file"/>
however, realize that, after added <data android:scheme="file"/>
, widget can no longer found in widgets list.
i encountered same issue , unable widgets appear <data>
tag in appwidgetprovider's intent filter, able create new receiver handled actions separately.
in androidmanifest.xml:
<receiver android:name="org.yccheok.gui.widgetmyappwidgetprovider" android:exported="true" > <intent-filter > <action android:name="android.appwidget.action.appwidget_update" /> <action android:name="android.appwidget.action.appwidget_enabled" /> <action android:name="android.appwidget.action.appwidget_deleted" /> <action android:name="android.appwidget.action.appwidget_disabled" /> <action android:name="android.appwidget.action.appwidget_options_changed" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info" /> </receiver> <receiver android:name="org.yccheok.gui.myotherprovider" android:exported="true" > <intent-filter > <action android:name="android.intent.action.media_mounted" /> <data android:scheme="file"/> </intent-filter> </receiver>
in new class myotherprovider.java:
package org.yccheok.gui.myotherprovider; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; public class myotherprovider extends broadcastreceiver { @override public void onreceive(context context, intent intent) { string action = intent.getaction(); if (intent.action_media_mounted.equals(action)) { // want // maybe call function in appwidgetprovider } } }
also, need include appwidget_update in intent filter, per http://developer.android.com/guide/topics/appwidgets/index.html#manifest
hope helps!
Comments
Post a Comment