简体   繁体   English

Android:小部件未显示在应用程序抽屉ICS中

[英]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. 该应用程序未安装在SD卡上。

Anyone have any ideas? 有人有想法么?

AndroidManifest.xml 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 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 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. 将“ minHeight”和“ minWidth”属性添加到每个appwidget的appwidget-provider元素中,看看这是否对您有用。

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. 如果在仿真器中运行logcat时检查它,您会注意到启动器会输出一条有关无效尺寸的消息,并且小部件名称将附加到此行。

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). Logcat消息说我的尺寸为(108,0)。 This lead me into looking at all my dimensions since it was yelling at me for height being 0. 这导致我查看了所有尺寸,因为高度为0时我大吼大叫。

This was my post: App Widget not displaying in ICS app drawer 这是我的文章: 应用程序小部件未显示在ICS应用程序抽屉中

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. 如果您的应用只是一个appwidget,除了配置之外没有任何活动,则您需要一个虚拟的main活动,以使您的appwidget出现在抽屉中。

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? 请参阅Google代码中的原始问题: http : //code.google.com/p/android/issues/detail?id=24208 ,此答案: Android 4.0:窗口小部件没有出现? 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) 以及Android Devs Google Group中的一个有趣的线程: https ://groups.google.com/forum/?fromgroups#! topic/ android-developers/bvlk3EOV6Xk(关于Honeycomb,但适用于Android 3.x及更高版本)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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