简体   繁体   中英

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>

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM