我的 PreferenceActivity 未显示,即使它位于我的清单文件中
所以我正在修改Cube动态壁纸示例。我有一个扩展 PreferenceActivity 的类,并且我在清单文件中添加了该 Activity。我不断收到 ActivityNotFoundExceptions。
这是我的首选项类:
package com.p.t.wallpapers.mywallpaper;
import com.p.t.wallpapers.mywallpaper.R;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class MySettingsActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(
ParticleCandy.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(
this);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
}
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.p.t.wallpapers.mywallpaper"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:label="@string/app_name"
android:name=".MyWallpaper"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action
android:name="android.service.wallpaper.WallpaperService">
</action>
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper_info" />
</service>
<activity
android:label="@string/settings_title"
android:name=".MySettingsActivity"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true">
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
</manifest>
您知道为什么我的首选项活动无法从清单中读取吗?壁纸服务 MyWallpaper 显示得很好,但 DDMS 一直告诉我 MySettingsActivity 活动没有退出。
这是 logcat 的输出
04-11 00:22:19.617: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
04-11 00:22:21.796: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2111 ms (total 2111 ms)
04-11 00:22:25.667: DEBUG/dalvikvm(375): GC freed 4745 objects / 316576 bytes in 192ms
04-11 00:22:25.727: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.p.t.wallpapers.mywallpaper/MySettingsActivity (has extras) }
04-11 00:22:25.757: DEBUG/AndroidRuntime(375): Shutting down VM
04-11 00:22:25.768: WARN/dalvikvm(375): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-11 00:22:25.787: ERROR/AndroidRuntime(375): Uncaught handler: thread main exiting due to uncaught exception
04-11 00:22:25.847: ERROR/AndroidRuntime(375): java.lang.IllegalStateException: Could not execute method of the activity
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2031)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.performClick(View.java:2364)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.onTouchEvent(View.java:4179)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.dispatchTouchEvent(View.java:3709)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: java.lang.reflect.InvocationTargetException
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2026)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 20 more
04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.p.t.wallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml?
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivity(Activity.java:2855)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 24 more
04-11 00:22:25.917: INFO/Process(57): Sending signal. PID: 375 SIG: 3
04-11 00:22:25.917: INFO/dalvikvm(375): threadid=7: reacting to signal 3
04-11 00:22:25.988: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin
04-11 00:22:26.012: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
04-11 00:22:26.044: INFO/dalvikvm(375): Wrote stack trace to '/data/anr/traces.txt'
04-11 00:22:29.307: INFO/Process(375): Sending signal. PID: 375 SIG: 9
04-11 00:22:29.516: INFO/ActivityManager(57): Process android.process.acore (pid 375) has died.
04-11 00:22:29.516: INFO/WindowManager(57): WIN DEATH: Window{44dd50d8 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 00:22:29.576: INFO/WindowManager(57): WIN DEATH: Window{44d660f8 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
04-11 00:22:29.586: INFO/WindowManager(57): WIN DEATH: Window{44dbe2f0 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 00:22:29.876: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=421 uid=10022 gids={}
04-11 00:22:30.687: DEBUG/ddm-heap(421): Got feature list request
04-11 00:22:30.957: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker
04-11 00:22:31.756: WARN/ResourceType(421): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 00:22:31.768: WARN/ResourceType(421): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 00:22:32.758: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 375 uid 10022
04-11 00:22:33.137: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3430 ms (total 3430 ms)
04-11 00:22:33.528: ERROR/gralloc(57): [unregister] handle 0x467ae8 still locked (state=40000001)
04-11 00:22:38.368: DEBUG/dalvikvm(364): GC freed 611 objects / 51656 bytes in 179ms
更新后的 logcat
04-11 01:10:52.976: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
04-11 01:10:53.668: WARN/InputManagerService(57): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44db02f8
04-11 01:10:54.587: INFO/ActivityManager(57): Displayed activity android/com.android.internal.app.ChooserActivity: 1140 ms (total 17760 ms)
04-11 01:10:56.458: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER flg=0x3000000 cmp=com.android.wallpaper.livepicker/.LiveWallpaperListActivity }
04-11 01:10:57.466: DEBUG/dalvikvm(1622): GC freed 1487 objects / 106648 bytes in 167ms
04-11 01:10:57.556: WARN/ResourceType(1622): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 01:10:57.587: WARN/ResourceType(1622): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 01:10:58.516: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 1625 ms (total 1625 ms)
04-11 01:11:00.717: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
04-11 01:11:02.948: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2187 ms (total 2187 ms)
04-11 01:11:11.538: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.p.t.wallpapers.mywallpaper/MySettingsActivity (has extras) }
04-11 01:11:11.577: DEBUG/AndroidRuntime(1622): Shutting down VM
04-11 01:11:11.587: WARN/dalvikvm(1622): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-11 01:11:11.597: ERROR/AndroidRuntime(1622): Uncaught handler: thread main exiting due to uncaught exception
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): java.lang.IllegalStateException: Could not execute method of the activity
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2031)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.performClick(View.java:2364)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.onTouchEvent(View.java:4179)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.dispatchTouchEvent(View.java:3709)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Looper.loop(Looper.java:123)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at dalvik.system.NativeStart.main(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: java.lang.reflect.InvocationTargetException
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2026)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 20 more
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.p.t.wallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml?
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivity(Activity.java:2855)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 24 more
04-11 01:11:11.748: INFO/Process(57): Sending signal. PID: 1622 SIG: 3
04-11 01:11:11.748: INFO/dalvikvm(1622): threadid=7: reacting to signal 3
04-11 01:11:11.827: INFO/dalvikvm(1622): Wrote stack trace to '/data/anr/traces.txt'
04-11 01:11:11.858: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin
04-11 01:11:11.877: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
04-11 01:11:13.788: DEBUG/dalvikvm(101): GC freed 3389 objects / 203632 bytes in 2805ms
04-11 01:11:16.787: INFO/Process(1622): Sending signal. PID: 1622 SIG: 9
04-11 01:11:17.037: INFO/ActivityManager(57): Process android.process.acore (pid 1622) has died.
04-11 01:11:17.046: INFO/WindowManager(57): WIN DEATH: Window{44db47b0 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 01:11:17.107: INFO/WindowManager(57): WIN DEATH: Window{44db7138 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
04-11 01:11:17.208: INFO/WindowManager(57): WIN DEATH: Window{44da6860 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 01:11:17.426: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=1647 uid=10022 gids={}
04-11 01:11:18.266: DEBUG/dalvikvm(30): GC freed 222 objects / 8512 bytes in 799ms
04-11 01:11:18.577: DEBUG/ddm-heap(1647): Got feature list request
04-11 01:11:18.686: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 406ms
04-11 01:11:19.037: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker
04-11 01:11:19.367: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 652ms
04-11 01:11:19.827: WARN/ResourceType(1647): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 01:11:19.837: WARN/ResourceType(1647): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 01:11:20.378: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 1622 uid 10022
04-11 01:11:20.737: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3496 ms (total 3496 ms)
04-11 01:11:21.117: ERROR/gralloc(57): [unregister] handle 0x448168 still locked (state=40000001)
04-11 01:23:24.496: DEBUG/dalvikvm(98): GC freed 12398 objects / 575024 bytes in 213ms
So I am modifying the Cube live wallpaper example. I have a class that extends PreferenceActivity, and I added the Activity in my manifest file. I keep getting ActivityNotFoundExceptions.
Here is my preference class :
package com.p.t.wallpapers.mywallpaper;
import com.p.t.wallpapers.mywallpaper.R;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class MySettingsActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(
ParticleCandy.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(
this);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
}
And here is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.p.t.wallpapers.mywallpaper"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:label="@string/app_name"
android:name=".MyWallpaper"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action
android:name="android.service.wallpaper.WallpaperService">
</action>
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper_info" />
</service>
<activity
android:label="@string/settings_title"
android:name=".MySettingsActivity"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true">
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
</manifest>
Any ideas why my preferences activity doesn't get read in from the manifest? The wallpaper service, MyWallpaper shows up just fine, but DDMS keeps telling me the activity MySettingsActivity doesn't exit.
Here is output from logcat
04-11 00:22:19.617: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
04-11 00:22:21.796: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2111 ms (total 2111 ms)
04-11 00:22:25.667: DEBUG/dalvikvm(375): GC freed 4745 objects / 316576 bytes in 192ms
04-11 00:22:25.727: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.p.t.wallpapers.mywallpaper/MySettingsActivity (has extras) }
04-11 00:22:25.757: DEBUG/AndroidRuntime(375): Shutting down VM
04-11 00:22:25.768: WARN/dalvikvm(375): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-11 00:22:25.787: ERROR/AndroidRuntime(375): Uncaught handler: thread main exiting due to uncaught exception
04-11 00:22:25.847: ERROR/AndroidRuntime(375): java.lang.IllegalStateException: Could not execute method of the activity
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2031)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.performClick(View.java:2364)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.onTouchEvent(View.java:4179)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.dispatchTouchEvent(View.java:3709)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: java.lang.reflect.InvocationTargetException
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2026)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 20 more
04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.p.t.wallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml?
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivity(Activity.java:2855)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 24 more
04-11 00:22:25.917: INFO/Process(57): Sending signal. PID: 375 SIG: 3
04-11 00:22:25.917: INFO/dalvikvm(375): threadid=7: reacting to signal 3
04-11 00:22:25.988: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin
04-11 00:22:26.012: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
04-11 00:22:26.044: INFO/dalvikvm(375): Wrote stack trace to '/data/anr/traces.txt'
04-11 00:22:29.307: INFO/Process(375): Sending signal. PID: 375 SIG: 9
04-11 00:22:29.516: INFO/ActivityManager(57): Process android.process.acore (pid 375) has died.
04-11 00:22:29.516: INFO/WindowManager(57): WIN DEATH: Window{44dd50d8 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 00:22:29.576: INFO/WindowManager(57): WIN DEATH: Window{44d660f8 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
04-11 00:22:29.586: INFO/WindowManager(57): WIN DEATH: Window{44dbe2f0 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 00:22:29.876: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=421 uid=10022 gids={}
04-11 00:22:30.687: DEBUG/ddm-heap(421): Got feature list request
04-11 00:22:30.957: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker
04-11 00:22:31.756: WARN/ResourceType(421): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 00:22:31.768: WARN/ResourceType(421): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 00:22:32.758: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 375 uid 10022
04-11 00:22:33.137: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3430 ms (total 3430 ms)
04-11 00:22:33.528: ERROR/gralloc(57): [unregister] handle 0x467ae8 still locked (state=40000001)
04-11 00:22:38.368: DEBUG/dalvikvm(364): GC freed 611 objects / 51656 bytes in 179ms
Updated logcat
04-11 01:10:52.976: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
04-11 01:10:53.668: WARN/InputManagerService(57): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44db02f8
04-11 01:10:54.587: INFO/ActivityManager(57): Displayed activity android/com.android.internal.app.ChooserActivity: 1140 ms (total 17760 ms)
04-11 01:10:56.458: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER flg=0x3000000 cmp=com.android.wallpaper.livepicker/.LiveWallpaperListActivity }
04-11 01:10:57.466: DEBUG/dalvikvm(1622): GC freed 1487 objects / 106648 bytes in 167ms
04-11 01:10:57.556: WARN/ResourceType(1622): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 01:10:57.587: WARN/ResourceType(1622): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 01:10:58.516: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 1625 ms (total 1625 ms)
04-11 01:11:00.717: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
04-11 01:11:02.948: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2187 ms (total 2187 ms)
04-11 01:11:11.538: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.p.t.wallpapers.mywallpaper/MySettingsActivity (has extras) }
04-11 01:11:11.577: DEBUG/AndroidRuntime(1622): Shutting down VM
04-11 01:11:11.587: WARN/dalvikvm(1622): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-11 01:11:11.597: ERROR/AndroidRuntime(1622): Uncaught handler: thread main exiting due to uncaught exception
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): java.lang.IllegalStateException: Could not execute method of the activity
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2031)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.performClick(View.java:2364)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.onTouchEvent(View.java:4179)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.dispatchTouchEvent(View.java:3709)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Looper.loop(Looper.java:123)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at dalvik.system.NativeStart.main(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: java.lang.reflect.InvocationTargetException
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2026)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 20 more
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.p.t.wallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml?
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivity(Activity.java:2855)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 24 more
04-11 01:11:11.748: INFO/Process(57): Sending signal. PID: 1622 SIG: 3
04-11 01:11:11.748: INFO/dalvikvm(1622): threadid=7: reacting to signal 3
04-11 01:11:11.827: INFO/dalvikvm(1622): Wrote stack trace to '/data/anr/traces.txt'
04-11 01:11:11.858: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin
04-11 01:11:11.877: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
04-11 01:11:13.788: DEBUG/dalvikvm(101): GC freed 3389 objects / 203632 bytes in 2805ms
04-11 01:11:16.787: INFO/Process(1622): Sending signal. PID: 1622 SIG: 9
04-11 01:11:17.037: INFO/ActivityManager(57): Process android.process.acore (pid 1622) has died.
04-11 01:11:17.046: INFO/WindowManager(57): WIN DEATH: Window{44db47b0 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 01:11:17.107: INFO/WindowManager(57): WIN DEATH: Window{44db7138 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
04-11 01:11:17.208: INFO/WindowManager(57): WIN DEATH: Window{44da6860 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 01:11:17.426: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=1647 uid=10022 gids={}
04-11 01:11:18.266: DEBUG/dalvikvm(30): GC freed 222 objects / 8512 bytes in 799ms
04-11 01:11:18.577: DEBUG/ddm-heap(1647): Got feature list request
04-11 01:11:18.686: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 406ms
04-11 01:11:19.037: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker
04-11 01:11:19.367: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 652ms
04-11 01:11:19.827: WARN/ResourceType(1647): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 01:11:19.837: WARN/ResourceType(1647): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 01:11:20.378: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 1622 uid 10022
04-11 01:11:20.737: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3496 ms (total 3496 ms)
04-11 01:11:21.117: ERROR/gralloc(57): [unregister] handle 0x448168 still locked (state=40000001)
04-11 01:23:24.496: DEBUG/dalvikvm(98): GC freed 12398 objects / 575024 bytes in 213ms
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
想通了。它是清单中引用的壁纸 xml,位于服务标签中的元数据标签下。基本上,该 xml
注意到那里有“MySettingsActivity”吗?是的,由于这是与清单分开的文件,因此它不会自动拥有从中开始搜索类名的包。所以我所要做的就是放置完整的包路径,就像这样
,瞧!当我点击“设置...”按钮时,我的首选项屏幕现在会弹出,而不是强制崩溃。天哪,捂脸!
Figured it out. It was the wallpaper xml that is referenced in the manifest, under the meta data tag in the service tag. Basically, that xml has
Notice the "MySettingsActivity" there? Yeah, since this is a separate file from the manifest, it doesn't automatically have a package it starts searching class names from. So all I had to do was put the full package path, like so
and voila! My preference screen pops up now when I hit the Settings... button, instead of force crashing. Oh man, facepalm!
我会在您的
android:name
属性上添加一个前导点(例如android:name=".MySettingsActivity"
)或完全限定其包(例如android:name="com.ptwallpapers.mywallpaper.MySettingsActivity"
)。另外,我会删除
import com.ptwallpapers.mywallpaper.R
,因为不需要它(您已经在该包中)并且可能会掩盖包问题。如果这些都没有帮助,请更新您的问题以解释您到底在哪里收到
ActivityNotFoundExceptions
。I would add a leading dot on your
android:name
attributes (e.g.,android:name=".MySettingsActivity"
) or fully-qualify their package (e.g.,android:name="com.p.t.wallpapers.mywallpaper.MySettingsActivity"
).Also, I would get rid of the
import com.p.t.wallpapers.mywallpaper.R
, as it should not be needed (you're already in that package) and might be masking a package problem.If neither of those help, please update your question to explain where, exactly, you are getting the
ActivityNotFoundExceptions
.第一个答案即添加
是正确的。这应该添加到描述标签的 xml 文件中。
如果你想摆脱设置崩溃删除
来自同一文件的 android:settingActivity 标记。
n njy 动态壁纸的美丽..
干杯,
印度希瓦姆萨布洛克
First answer ie adding
is correct. this should be added into the xml file which describes the tag.
if you want to get rid of the Settings crash delete the
android:settingActivity tag from the same file.
n njy the beauty of live wallpaper..
cheers,
Shivam Sabhlok, India
确保您的
MySettingsActivity
位于com.ptwallpapers.mywallpaper
包中,否则您必须指定绝对包名称。Make sure your
MySettingsActivity
is in thecom.p.t.wallpapers.mywallpaper
package, otherwise you have to specify the absolute package name.