简体   繁体   English

App Widget未显示在ICS app抽屉中

[英]App Widget not displaying in ICS app drawer

Has anyone experienced their app widget not being listed in the ICS app drawer? 有没有人经历过他们的app小部件未被列入ICS应用程序抽屉?

Originally I started this app for FroYo and below, which supports the app widget just fine. 最初我开始使用FroYo及以下版本的应用程序,它支持app小部件就好了。 Along came Gingerbread and Honeycomb, those work too. 随之而来的是Gingerbread和Honeycomb,这些也是如此。

The widget appears in the list in the emulator if I open up the "Widget Preview" app, however when you just open the drawer it isn't listed with the others. 如果我打开“小部件预览”应用程序,小部件将出现在模拟器的列表中,但是当您打开抽屉时,它不会与其他小部件一起列出。 It does appear on Honeycomb. 它确实出现在Honeycomb上。 I don't (and others haven't also) see it on my Galaxy Nexus anywhere either. 我不(也有其他人也没有)在我的Galaxy Nexus上看到它。

I've tried rebooting as I've seen that solving the problem for some people after initial installation. 我尝试重新启动,因为我已经看到在初始安装后为某些人解决问题。 Also I do have a main activity with the action.MAIN/category.LAUNCHER intent filter since I have app activities, this isn't a widget only type of project. 我也有一个主要的活动与action.MAIN / category.LAUNCHER意图过滤器,因为我有应用程序活动,这不是一个仅限小部件的项目类型。

I'll post some snippets below, let me know if more is needed. 我将在下面发布一些片段,如果需要更多,请告诉我。 My minSdkVersion is at 7 and targetSdkVersion at 15, project properties also has the target checked at 4.0.3. 我的minSdkVersion为7,targetSdkVersion为15,项目属性的目标也是4.0.3。 The installLocation attribute is set to auto. installLocation属性设置为auto。

AndroidManifest.xml: AndroidManifest.xml中:

<receiver android:name=".AppWidget" android:label="@string/one_cell_widget_label">
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <intent-filter>
        <action android:name="com.frankcalise.h2droid.FORCE_WIDGET_UPDATE" />
    </intent-filter>
    <meta-data
        android:name="android.appwidget.provider"
        android:resource="@xml/one_cell_widget_settings" />
</receiver>

one_cell_widget_settings.xml: one_cell_widget_settings.xml:

<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/one_cell_widget"
    android:minWidth="@dimen/one_cell_widget"
    android:maxHeight="@dimen/one_cell_widget"
    android:updatePeriodMillis="0" >
</appwidget-provider>

one_cell_widget.xml: one_cell_widget.xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget_background"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/widget_margin"
    android:background="@drawable/widget_background">
    <TextView
        android:id="@+id/widget_title_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/app_name"
        android:textColor="@android:color/black" />
    <TextView
        android:id="@+id/widget_amount_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/default_widget_amount"
        android:textSize="12sp"
        android:textColor="@color/amount_color" />
    <TextView
        android:id="@+id/widget_percent_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/default_widget_percent" />
</LinearLayout>

and then obviously I implemented the class in AppWidget.java 然后显然我在AppWidget.java中实现了这个类

public class AppWidget extends AppWidgetProvider

UPDATE: 更新:

An important logcat message I found earlier today which helped me solve the issue: 我今天早些时候发现的一条重要的logcat消息帮助我解决了这个问题:

06-01 14:41:31.606: E/AppsCustomizePagedView(199): Widget ComponentInfo{com.frankcalise.h2droid/com.frankcalise.h2droid.AppWidget} has invalid dimensions (108, 0)

I found the issue. 我发现了这个问题。 My appwidget-provider element has a typo in one of the attributes, it should say "minHeight", not "maxHeight". 我的appwidget-provider元素在其中一个属性中有一个拼写错误,应该说“minHeight”,而不是“maxHeight”。

What lead me to finding this was finding an error output in logcat from the launcher. 让我发现这一点的原因是从启动器中找到logcat中的错误输出。 It mentioned my widget had invalid dimensions (therefore it didn't add it to the list of widgets). 它提到我的小部件具有无效的维度(因此它没有将其添加到小部件列表中)。 So then I started checking all the dimension attributes related to my widget. 然后我开始检查与我的小部件相关的所有维度属性。

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

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