5

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>
FuegoFingers
  • 2,181
  • 6
  • 27
  • 36
  • 2
    I have noticed that when I install new apps their widgets sometimes do not show up in the widget section until I have rebooted my phone. This is not an official build of 4.0.3, so I always assumed it was something wrong with my build, but maybe you are seeing the same problem? – Kaediil Feb 10 '12 at 20:48
  • 1
    I have the same problem as well. Seems like it's cached some how.. – Ran Feb 11 '12 at 20:29
  • Unfortunately this isn't fixing the problem. – FuegoFingers Feb 13 '12 at 16:33
  • Frustrating, I'm experiencing the same issue. The reboot wasn't a fix. Your widget appears for Honeycomb and below though, correct? – esilac May 31 '12 at 21:38

2 Answers2

4

Add "minHeight" and "minWidth" attributes to your appwidget-provider elements for each of your appwidgets and see if this does the trick for you.

If you check logcat when running it in the emulator, you should notice the launcher outputting a message about invalid dimensions and the name of your widget will be attached to this line.

I just had this issue and this is how I solved it (although I had one min and on max provided on accident). The logcat message said I had a dimension of (108, 0). This lead me into looking at all my dimensions since it was yelling at me for height being 0.

This was my post: App Widget not displaying in ICS app drawer

Community
  • 1
  • 1
esilac
  • 789
  • 7
  • 16
2

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)

Community
  • 1
  • 1
Jose_GD
  • 2,279
  • 1
  • 21
  • 34