Android StackWidget无法绑定

发布于 2025-01-05 00:09:39 字数 2762 浏览 2 评论 0原文

我目前正在尝试向我的应用程序添加一个小部件,并且我的实现基于此代码 http://developer.android.com/resources/samples/StackWidget/index.html

我已将所有与堆栈小部件相关的类放入主包中自己的包中。Package setyp

当我尝试添加小部件时,它无法绑定,因此不会显示卡片(它只是说明默认文本“这是空视图”)

下面是我的清单。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bencallis.dealpad" android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/ic_launcher"
        android:logo="@drawable/logo" android:theme="@style/DealPadTheme"
        android:hardwareAccelerated="true" android:uiOptions="splitActionBarWhenNarrow">
        <activity android:label="@string/app_name" android:name=".DealPadActivity"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SettingsActivity" />
        <activity android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />


        <!-- Widgets -->
        <receiver android:name=".stackwidget.StackWidgetProvider">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/stackwidgetinfo" />
        </receiver>

        <service android:name="stackwidget.StackWidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS"
            android:exported="false" />


    </application>

</manifest>

错误消息:

E/RemoteViewsAdapterServiceConnection(474): bind(): Unknown component ComponentInfo{com.bencallis.dealpad/com.bencallis.dealpad.stackwidget.StackWidgetService}

我确信某个地方存在一个简单的错误,导致组件信息重复 com.bencallis.dealpad。

有什么想法吗?

I am currently trying to add a widget to my application and have been basing my implementation on this code http://developer.android.com/resources/samples/StackWidget/index.html

I have put all my stack widget related classes in their own package within my main package.Package setyp

When I try to add the widget it is unable to bind and hence the cards are not displayed (it just states the default text "This is the empty view")

Below is my manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bencallis.dealpad" android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application android:icon="@drawable/ic_launcher"
        android:logo="@drawable/logo" android:theme="@style/DealPadTheme"
        android:hardwareAccelerated="true" android:uiOptions="splitActionBarWhenNarrow">
        <activity android:label="@string/app_name" android:name=".DealPadActivity"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SettingsActivity" />
        <activity android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />


        <!-- Widgets -->
        <receiver android:name=".stackwidget.StackWidgetProvider">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/stackwidgetinfo" />
        </receiver>

        <service android:name="stackwidget.StackWidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS"
            android:exported="false" />


    </application>

</manifest>

Error message:

E/RemoteViewsAdapterServiceConnection(474): bind(): Unknown component ComponentInfo{com.bencallis.dealpad/com.bencallis.dealpad.stackwidget.StackWidgetService}

I am sure there is a simple mistake somewhere which is making the component info repeat com.bencallis.dealpad.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光是把杀猪刀 2025-01-12 00:09:39

事实证明,这与我的清单和定位服务的问题有关。我缺少一个 .在名称中(给出路径)。

愚蠢的错误!

It turned out it was to do with my manifest and a problem locating the service. I was missing a . in the name (which gives it the path).

Silly mistake!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文