03-11 15:03:32.743: E/AndroidRuntime(1556): FATAL EXCEPTION: main
03-11 15:03:32.743: E/AndroidRuntime(1556): Process: com.example.takipci, PID: 1556
03-11 15:03:32.743: E/AndroidRuntime(1556): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.takipci/com.example.takipci.AyarlarActivity}: java.lang.RuntimeException: Subclasses of PreferenceActivity must override isValidFragment(String) to verify that the Fragment class is valid! com.example.takipci.AyarlarActivity has not checked if fragment com.example.takipci.fragment.GizlilikPreferencesFragment is valid.
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.os.Handler.dispatchMessage(Handler.java:102)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.os.Looper.loop(Looper.java:136)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-11 15:03:32.743: E/AndroidRuntime(1556): at java.lang.reflect.Method.invokeNative(Native Method)
03-11 15:03:32.743: E/AndroidRuntime(1556): at java.lang.reflect.Method.invoke(Method.java:515)
03-11 15:03:32.743: E/AndroidRuntime(1556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-11 15:03:32.743: E/AndroidRuntime(1556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-11 15:03:32.743: E/AndroidRuntime(1556): at dalvik.system.NativeStart.main(Native Method)
03-11 15:03:32.743: E/AndroidRuntime(1556): Caused by: java.lang.RuntimeException: Subclasses of PreferenceActivity must override isValidFragment(String) to verify that the Fragment class is valid! com.example.takipci.AyarlarActivity has not checked if fragment com.example.takipci.fragment.GizlilikPreferencesFragment is valid.
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.preference.PreferenceActivity.isValidFragment(PreferenceActivity.java:898)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.preference.PreferenceActivity.switchToHeaderInner(PreferenceActivity.java:1179)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.preference.PreferenceActivity.switchToHeader(PreferenceActivity.java:1199)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:545)
03-11 15:03:32.743: E/AndroidRuntime(1556): at com.example.takipci.AyarlarActivity.onCreate(AyarlarActivity.java:20)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.Activity.performCreate(Activity.java:5231)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-11 15:03:32.743: E/AndroidRuntime(1556): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-11 15:03:32.743: E/AndroidRuntime(1556): ... 11 more
答案 0 :(得分:1)
例外情况:
PreferenceActivity的子类必须覆盖isValidFragment(String) 验证Fragment类是否有效! com.example.takipci.AyarlarActivity尚未检查片段 com.example.takipci.fragment.GizlilikPreferencesFragment有效。
在AyarlarActivity
中,您需要添加以下内容:
@Override
protected boolean isValidFragment(String fragmentName) {
return GizlilikPreferencesFragment.class.getName().equals(fragmentName)
|| super.isValidFragment(fragmentName);
}
答案 1 :(得分:0)
尝试将您的API版本更改为18或更低,它似乎是KitKat安全限制
<uses-sdk android:targetSdkVersion="18" />