[英]Android Studio Settings Activity doesn't work
As far as I can understand from the documentation the settings activity which comes as a template with Android Studio should work. 据我所知,从文档中可以看出,作为Android Studio模板的设置活动应该可行。 However, it doesn't seem to launch anything on my phone.
但是,它似乎没有在我的手机上启动任何东西。
I understand that it's meant to work for both tablets and phones. 我知道它适用于平板电脑和手机。 I'm running Android 5.0 and I have successfully used it as a test device before.
我正在运行Android 5.0,之前我已成功将其用作测试设备。 I have yet to test it on a tablet.
我还没有在平板电脑上测试它。
Well, I'm using the default template that's supplied with android studio for the settings activity. 好吧,我正在使用android studio提供的默认模板进行设置活动。 I didn't post it since it extends across several pages (5 xml files and 1 class file).
我没有发布它,因为它扩展到几个页面(5个xml文件和1个类文件)。
http://www.pastebin.com/kehbMSqg -SettingsActivity.class. http://www.pastebin.com/kehbMSqg -SettingsActivity.class。 (That's the class which I set to launch.)
(这是我设定推出的课程。)
http://pastebin.com/GHjZRn68 -pref_data_sync.xml http://pastebin.com/GHjZRn68-pref_data_sync.xml
http://pastebin.com/0FaaH8zR -pref_general.xml http://pastebin.com/0FaaH8zR -pref_general.xml
http://pastebin.com/yixMwAaJ -pref_headers.xml http://pastebin.com/yixMwAaJ -pref_headers.xml
http://pastebin.com/46W1dREG -pref_notification.xml http://pastebin.com/46W1dREG -pref_notification.xml
Any help would be useful Thanks! 任何帮助都会有用谢谢!
This may be related to a fix for a fragment injection vulnerability that was patched in KITKAT. 这可能与修复KITKAT中修补的片段注入漏洞有关。 If you are running the app for a targetSdkVersion since KITKAT, an exception will be thrown when the SettingsActivity tries to launch a PreferenceFragment.
如果您从KITKAT开始运行targetSdkVersion的应用程序,则当SettingsActivity尝试启动PreferenceFragment时将抛出异常。
You need to override the PreferenceActivity.isValidFragment()
method. 您需要覆盖
PreferenceActivity.isValidFragment()
方法。 For the Settings Activity template in Android Studio 1.3.2 you can use: 对于Android Studio 1.3.2中的“设置活动”模板,您可以使用:
@Override
protected boolean isValidFragment(String fragmentName) {
return fragmentName.equals(GeneralPreferenceFragment.class.getName())
|| fragmentName.equals(NotificationPreferenceFragment.class.getName())
|| fragmentName.equals(DataSyncPreferenceFragment.class.getName());
}
Related stackoverflow post: isValidFragment Android API 19 相关的stackoverflow帖子: isValidFragment Android API 19
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.