Search code examples
androidandroid-widgethomescreen

Android: Widgets not showing in app drawer ICS


I have two widgets and neither of them will show up in the app drawer. What's weird is that if I remove one from the manifest it won't show up either but I can't see what I am doing wrong. From all the other questions I searched it looks right. The app is not being installed on the SD card.

Anyone have any ideas?

AndroidManifest.xml

<receiver
        android:name=".appwidgets.WidgetLarge"
        android:label="@string/Widget_large"
        android:icon="@drawable/icon" >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.groggs.action.CACHE_UPDATE_FINISHED" />
        </intent-filter>
        <intent-filter>
            <action android:name="WIDGET_UPDATE" />
            <data android:scheme="content" />
        </intent-filter>

        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/widget_large_info" />
    </receiver>

    <receiver
        android:name=".appwidgets.WidgetSmall"
        android:label="@string/Widget_small"
        android:icon="@drawable/icon" >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.groggs.action.CACHE_UPDATE_FINISHED" />
        </intent-filter>
        <intent-filter>
            <action android:name="WIDGET_UPDATE" />

            <data android:scheme="content" />
        </intent-filter>

        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/widget_small_info" />
    </receiver>

widget_large_info.xml

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:maxWidth="450dp"
    android:maxHeight="352dp" 
    android:updatePeriodMillis="0"
    android:initialLayout="@layout/widget_layout_large"
    android:configure="com.groggs.appwidgets.config.HubQuickViewWidgetConfig" >
</appwidget-provider>

widget_small_info.xml

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:maxWidth="450dp"
    android:maxHeight="82dp" 
    android:updatePeriodMillis="0"
    android:initialLayout="@layout/widget_layout_small"
    android:configure="com.groggs.appwidgets.config.HubQuickViewWidgetConfig" >
</appwidget-provider>

Solution

  • If your app is only an appwidget, with no activities besides a configuration one, you need a dummy main activity to make your appwidget appear in the drawer.

    See the original issue in Google Code: http://code.google.com/p/android/issues/detail?id=24208, this answer: Android 4.0: widgets not appearing? and also this interesting thread in Android Devs Google Group: https://groups.google.com/forum/?fromgroups#!topic/android-developers/bvlk3EOV6Xk (it's about Honeycomb, but applies to Android versions 3.x and greater)