2011-11-27 106 views
1

當我嘗試啓動我的動態壁紙設置按鈕時,我得到一個「動態壁紙選擇器(process.android.process.acore)意外停止。」我不確定爲什麼。我正在使用andengine。動態壁紙設置不顯示

這是我的主要(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) 
    { 

    } 

這裏是我的(Settings.java)文件:

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) 
{ 

} 
} 

的(mjs.xml)文件:

<?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"/> 

最後(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> 

//編輯\ 我的AndroidManifest.xml文件:

<?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> 

這是我logcat的時候我得到的錯誤:

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. 
+0

請發佈您的logcat,以便我們知道問題發生在哪裏。另外,請提供AndroidManifest.xml文件。 – Huang

+0

謝謝,我發佈了兩個。 – MJ93

回答

1

我有固定的問題。看來我只好我的AndroidManifest.xml從改變:

<activity android:name="Settings"></activity> 

到:

<activity android:name="Settings"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN"> 
     </action> 
    </intent-filter> 
</activity> 

logcat的工程奇蹟:)在清單文件您的喜好活動的聲明

+0

嘿,我開發了一個LiveWallpaper。在我的AndroidManifest.xml文件,我宣佈它:\t \t <活動機器人:名字=機器人 「設置」:標籤= 「@字符串/ APP_NAME」 \t \t \t機器人:出口= 「真」> 我已經測試你的方式來宣佈活動。兩者都很好。 – Huang

0

使用android:exported="true"標籤。

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). 

沒有這一點,動態壁紙選擇器不能叫你的壁紙的活動。