Reputation: 5296
When I try to launch the settings button for my Live Wallpaper I get a "Live Wallpaper Picker (process.android.process.acore) has stopped unexpectedly." And I'm not really sure why. I am using andengine.
This is inside my main (ParticleWallpaperActivity.java):
package com.particle.wallpaper;
import javax.microedition.khronos.opengles.GL10;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.particle.ParticleSystem;
import org.anddev.andengine.entity.particle.emitter.PointParticleEmitter;
import org.anddev.andengine.entity.particle.initializer.AccelerationInitializer;
import org.anddev.andengine.entity.particle.initializer.ColorInitializer;
import org.anddev.andengine.entity.particle.initializer.RotationInitializer;
import org.anddev.andengine.entity.particle.initializer.VelocityInitializer;
import org.anddev.andengine.entity.particle.modifier.AlphaModifier;
import org.anddev.andengine.entity.particle.modifier.ColorModifier;
import org.anddev.andengine.entity.particle.modifier.ExpireModifier;
import org.anddev.andengine.entity.particle.modifier.ScaleModifier;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import android.content.SharedPreferences;
public class ParticleWallpaperActivity extends BaseLiveWallpaperService implements SharedPreferences.OnSharedPreferenceChangeListener {
// ===========================================================
// Constants
// ===========================================================
public static final String SHARED_PREFS_NAME = "preferences";
private static final int CAMERA_WIDTH = 480;
private static final int CAMERA_HEIGHT = 320;
private static final float RATE_MIN = 8;
private static final float RATE_MAX = 12;
private static final int PARTICLES_MAX = 200;
// ===========================================================
// Fields
// ===========================================================
private Camera mCamera;
private BitmapTextureAtlas mBitmapTextureAtlas;
private TextureRegion mParticleTextureRegion;
//Shared Preferences
private SharedPreferences mSharedPreferences;
.....
.....
.....
@Override
public void onSharedPreferenceChanged(SharedPreferences pSharedPrefs, String pKey)
{
}
Here is my (Settings.java) file:
package com.particle.wallpaper;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class Settings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener
{
@Override
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
getPreferenceManager().setSharedPreferencesName(ParticleWallpaperActivity.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.preferences);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onResume()
{
super.onResume();
}
@Override
protected void onDestroy()
{
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy();
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
}
}
The (mjs.xml) file:
<?xml version="1.0" encoding="UTF-8"?>
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="@drawable/icon"
android:description="@string/app_description"
android:settingsActivity="com.particle.wallpaper.Settings"/>
And finally (preferences.xml):
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="First Category">
</PreferenceCategory>
</PreferenceScreen>
//EDIT\ My AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.particle.wallpaper"
android:versionCode="46"
android:versionName="1.4.6">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:name="ParticleWallpaperActivity"
android:enabled="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter android:priority="1" >
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/mjs" />
</service>
<activity android:name="Settings"></activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
</manifest>
Here is my logcat when I get the error:
11-27 23:29:28.593: W/dalvikvm(572): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
11-27 23:29:28.593: E/AndroidRuntime(572): Uncaught handler: thread main exiting due to uncaught exception
11-27 23:29:28.694: E/AndroidRuntime(572): java.lang.IllegalStateException: Could not execute method of the activity
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.View$1.onClick(View.java:2031)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.View.performClick(View.java:2364)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.View.onTouchEvent(View.java:4179)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.widget.TextView.onTouchEvent(TextView.java:6541)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.View.dispatchTouchEvent(View.java:3709)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow. java:1659)
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPrevi ew.java:199)
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java: 1643)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.os.Looper.loop(Looper.java:123)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.app.ActivityThread.main(ActivityThread.java:4363)
11-27 23:29:28.694: E/AndroidRuntime(572): at java.lang.reflect.Method.invokeNative(Native Method)
11-27 23:29:28.694: E/AndroidRuntime(572): at java.lang.reflect.Method.invoke(Method.java:521)
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-27 23:29:28.694: E/AndroidRuntime(572): at dalvik.system.NativeStart.main(Native Method)
11-27 23:29:28.694: E/AndroidRuntime(572): Caused by: java.lang.reflect.InvocationTargetException
11-27 23:29:28.694: E/AndroidRuntime(572): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperP review.java:113)
11-27 23:29:28.694: E/AndroidRuntime(572): at java.lang.reflect.Method.invokeNative(Native Method)
11-27 23:29:28.694: E/AndroidRuntime(572): at java.lang.reflect.Method.invoke(Method.java:521)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.view.View$1.onClick(View.java:2026)
11-27 23:29:28.694: E/AndroidRuntime(572): ... 20 more
11-27 23:29:28.694: E/AndroidRuntime(572): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.particle.wallpaper/.Settings (has extras) } from ProcessRecord{43db8760 572:android.process.acore/10022} (pid=572, uid=10022) requires null
11-27 23:29:28.694: E/AndroidRuntime(572): at android.os.Parcel.readException(Parcel.java:1218)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.os.Parcel.readException(Parcel.java:1206)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1214)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.app.Activity.startActivityForResult(Activity.java:2749)
11-27 23:29:28.694: E/AndroidRuntime(572): at android.app.Activity.startActivity(Activity.java:2855)
11-27 23:29:28.694: E/AndroidRuntime(572): ... 24 more
There must be something very simple that I'm missing, but I just can't seem to figure it out. Any help would be greatly appreciated.
Upvotes: 1
Views: 3850
Reputation: 1582
Use android:exported="true"
tag in your preference activity declaration in Manifest file.
From Android Developers
android:exported
Whether or not components of other applications can invoke the service or interact with it — "true" if they can, and "false" if not. When the value is "false", only components of the same application or applications with the same user ID can start the service or bind to it.
The default value depends on whether the service contains intent filters. The absence of any filters means that it can be invoked only by specifying its exact class name. This implies that the service is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the service is intended for external use, so the default value is "true". This attribute is not the only way to limit the exposure of a service to other applications. You can also use a permission to limit the external entities that can interact with the service (see the permission attribute).
Without this, live wallpaper chooser cannot call activity of your wallpaper.
Upvotes: 0
Reputation: 5296
I have fixed the problem. It seems I had to change my AndroidManifest.xml from:
<activity android:name="Settings"></activity>
to:
<activity android:name="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN">
</action>
</intent-filter>
</activity>
Logcat works wonders :)
Upvotes: 1