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

2 回答 2

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);
}
于 2014-03-11T19:20:52.253 回答
0

尝试将您的 API 版本更改为 18 或更低,这似乎是 KitKat 安全限制

<uses-sdk android:targetSdkVersion="18" />
于 2014-03-11T19:23:28.687 回答