6

I'm having a force close problem whenever I try to launch the settings for my live wallpaper. I don't really have anything there, so I'm not sure what could possibly be causing the problem... Here is the logCat

03-17 02:13:55.262: ERROR/AndroidRuntime(12429): FATAL EXCEPTION: main
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): java.lang.IllegalStateException: Could not execute method of the activity
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.view.View$1.onClick(View.java:2072)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.view.View.performClick(View.java:2408)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.view.View$PerformClick.run(View.java:8818)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.os.Handler.handleCallback(Handler.java:587)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.os.Looper.loop(Looper.java:143)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.app.ActivityThread.main(ActivityThread.java:4701)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at java.lang.reflect.Method.invokeNative(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at java.lang.reflect.Method.invoke(Method.java:521)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at dalvik.system.NativeStart.main(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): Caused by: java.lang.reflect.InvocationTargetException
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at java.lang.reflect.Method.invokeNative(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at java.lang.reflect.Method.invoke(Method.java:521)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.view.View$1.onClick(View.java:2067)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     ... 11 more
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.SSTSoft.BallInABox/.BallInABoxSettings (has extras) } from ProcessRecord{45b9eb18 12429:com.android.wallpaper.livepicker/10050} (pid=12429, uid=10050) requires null
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.os.Parcel.readException(Parcel.java:1247)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.os.Parcel.readException(Parcel.java:1235)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.app.Activity.startActivityForResult(Activity.java:2817)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     at android.app.Activity.startActivity(Activity.java:2923)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429):     ... 15 more

I think it's that permission denial line, but I have no clue what could be causing it... Is there some hidden permission I need to set? This is my first liveWallpaper.

Thanks!

George Freeman
  • 2,260
  • 1
  • 15
  • 22
Matt
  • 2,650
  • 4
  • 36
  • 46

3 Answers3

15

Ugh, I found the problem... It turns out I needed the preference activity in the manifest have exported set to "true". There's an hour I'll never get back!

Matt
  • 2,650
  • 4
  • 36
  • 46
7

While the accepted answer definitely works, it's not the correct way to do it. Setting export to true just means the activity can be launched outside of your application. However, the way this should be done is to declare the activity like this:

    <activity android:name="com.example.SettingsActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
gsgx
  • 12,020
  • 25
  • 98
  • 149
1

Yes, you need to set the SET_WALLPAPER permission in Android manifest file. You can use the following line inside the <manifest></manifest> element;

<uses-permission android:name="android.permission.SET_WALLPAPER" />

Update:

Reference: <uses-permission> element.

Mudassir
  • 13,031
  • 8
  • 59
  • 87
  • I actually think I found the fix to the problem, but I'm curious about this. Is this permission for the settings activity, or the service itself? My service has the permission of BIND_WALLPAPER right now, not SET_WALLPAPER. Thanks. – Matt Mar 17 '11 at 09:36
  • You need SET_WALLPAPER permission, if you are setting the wallpaper. – Mudassir Mar 17 '11 at 09:38
  • Strange, it's working on my device with BIND_WALLPAPER. Is this for the settings activity, or the wallpaper service? Thanks. – Matt Mar 17 '11 at 09:52