尝试在HomeScreen中安装appWidget时获取SecurityException

时间:2010-11-30 18:40:11

标签: android

我在这里遇到一点麻烦。当我试图在主屏幕上安装我的AppWidget时,我不知道为什么我会收到SecurityException?我不知道什么会有助于解决这个问题,但这里是简化的logcat输出和我的Android Manifest for starters:

11-30 18:02:16.454: ERROR/AndroidRuntime(287): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.appwidget.action.APPWIDGET_CONFIGURE cmp=com.MuchachaApps.WeatherViewer/.WeatherForecastConfigure (has extras) } from ProcessRecord{44e58dc8 287:android.process.acore/10001} (pid=287, uid=10001) requires null
11-30 18:02:16.454: ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1218)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1206)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1214)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.startActivityForResult(Activity.java:2749)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.startActivityForResult(Launcher.java:969)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.addAppWidget(Launcher.java:1148)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.onActivityResult(Launcher.java:379)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.dispatchActivityResult(Activity.java:3828)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityThread.deliverResults(ActivityThread.java:3325)
11-30 18:02:16.454: ERROR/AndroidRuntime(287):... 11 more

我的Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.MuchaaApps.WeatherViewer"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <service android:name= "weatherForecast"></service>

<activity android:name=".WeatherForecastConfigure" android:label="@string/app_name"></activity>

<receiver android:name="WeatherWidgetProvider" android:label="Weather Forecast">
     <intent-filter> 
       <action android:name= "android.appwidget.action.APPWIDGET_UPDATE"></action>
     </intent-filter>
      <intent-filter>
       <action android:name="com.MuchaaApps.WeatherViewer.WEATHER_UPDATE"></action>
       </intent-filter>
            <meta-data android:name="android.appwidget.provider"
             android:resource="@xml/weather_appwidget_info"></meta-data>
        </receiver>
    </application>

    <uses-sdk android:minSdkVersion="4" />
    <uses-permission android:name="android.permission.INTERNET"/>

</manifest> 

如果您需要任何其他信息,请告诉我。谢谢

1 个答案:

答案 0 :(得分:4)

当您将小部件添加到启动器时,是否有应该出现的配置活动?如果是这样,您需要向intent-filter添加APPWIDGET_CONFIGURE操作。如果没有,则需要从appwidget-provider XML中删除android:configure属性。

有一个但不是另一个是问题。