1

我这里有一个基本的时钟小部件,它在 4.0 以下的 android 版本上工作得很好,你可以长按,选择小部件,它就在那里。但是当我尝试在 4.0 或更高版本的模拟器或真实设备上运行它时,它不会仅在设置>存储>应用程序中的小部件部分显示。我尝试添加一个简单的活动,它只是为用户提供有关如何安装小部件的指示,该建议在此处作为答案给出:Android 4.0:小部件未出现? . 除非我做错了,否则小部件仍然不会出现在小部件抽屉中。

这是我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.widgetexample1"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="14" />
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
       <activity android:name=".MainActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />                
        </intent-filter>
    </activity>
        <receiver android:name=".ExampleAppWidgetProvider"
            android:label="8-bit cloud widget 1">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />

                </intent-filter>
                <meta-data android:name="android.appwidget.provider"
                    android:resource="@xml/widget1_info" />
        </receiver>
    </application>

</manifest>
4

3 回答 3

0

在您的 manifest.xml 中添加以下内容。“android:exported="true"。它可能会有所帮助。试试看。

于 2012-08-11T09:25:35.483 回答
0

看起来您正在受到我认为发生在 HoneyComb 中的安全升级的打击。

基本上,在较新版本的 Android 中,如果不先启动Activity.

所以向项目添加一个活动,首先运行它,我认为你的小部件会更新。

一个很好的例子是使用设置风格的活动,或者可能和关于框类型的东西,告诉用户一些关于你的小部件的信息。(我在我的小部件中使用设置)。


欲了解更多信息:

于 2013-07-16T10:42:58.633 回答
0

在您的小部件元数据 xml 文件中,检查标记<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"android:xmlns 属性应以http://.

于 2012-12-13T21:55:00.850 回答