动态壁纸设置不显示

发布于 2024-12-18 10:27:47 字数 10238 浏览 2 评论 0原文

当我尝试启动动态壁纸的设置按钮时,出现“动态壁纸选择器 (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>

//EDIT\ 我的 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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离线来电— 2024-12-25 10:27:47

我已经解决了这个问题。看来我必须将 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 创造奇迹:)

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

野却迷人 2024-12-25 10:27:47

在清单文件中的首选项活动声明中使用 android:exported="true" 标记。


Android 开发者

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

如果没有这个,动态壁纸选择器就无法调用您的活动墙纸。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文