I\'m upgrading my app with widget. It\'s not the first widget I\'ve done. I was always encountering weird issues, but the widget was shwoing up on the list eventually.
You need to register a BroadcastReceiver in the manifest file. For example:
<receiver
android:icon="@drawable/icon"
android:label="Example Widget"
android:name="MyWidgetProvider" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
I borrowed this code from http://www.vogella.com/articles/AndroidWidgets/article.html
See the link for a full tutorial
Ran across similar issues and this is what happened for me. The below Widget never showed up in the Widget drawer till minResizeHeight was added. Weird, but may be that is required for resizable widget. Could have been more friendly.
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/pmt_schedule_scroll_widget"
android:minHeight="146dip"
android:minResizeHeight="73dp"
android:minWidth="146dip"
android:resizeMode="vertical"
android:updatePeriodMillis="0" />
I tried every possible solution and nothing worked for me... And finally I solved it.
In my case the problem was overthinking: I believed that in meta-data tag we need to define a unique name for provider (eg: "com.example.myprovider") as well as link to the xml resource.
Wrong:
<meta-data
android:name="com.example.myprovider"
android:resource="@xml/widget_info" />
Right:
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
after hours of searching and failing to resolve, I decided to open a sample project of a widget that works and go comparing item by item to see what was wrong, in the end, I solve added the following lines on my res/xml/widget_info.xml:
android:minHeight="XXXdp"
android:minResizeHeight="XXXdp"
android:minResizeWidth="XXXdp"
android:minWidth="XXXdp"
where XXX is some value.
The problem was android:installLocation="preferExternal"
It somehow causes problem with widget list if the app is installed on SD
In my case, it was the minWidth, it was too large, just put a smaller dp, it works also with a minHeight too height as well!