2015-02-23 68 views
0

据我可以从文档中了解到,设置活动作为模板与Android Studio应该工作。但是,它似乎没有在我的手机上启动任何东西。Android Studio设置活动不起作用

我知道它意味着可以同时用于平板电脑和手机。 我正在运行Android 5.0,并且之前成功将它用作测试设备。 我还没有在平板电脑上测试它。

那么,我正在使用android studio提供的默认模板进行设置活动。我没有发布它,因为它跨越了几个页面(5个xml文件和1个类文件)。

http://www.pastebin.com/kehbMSqg -SettingsActivity.class。 (这是我将推出类。)

http://pastebin.com/GHjZRn68 -pref_data_sync.xml

http://pastebin.com/0FaaH8zR -pref_general.xml

http://pastebin.com/yixMwAaJ -pref_headers.xml

http://pastebin.com/46W1dREG -pref_notification.xml

任何帮助将是有用的 谢谢!

+0

码? Logcat如何? – 2015-02-23 16:40:44

+0

当你在SO上提出问题时,如果出现任何错误,也可以将相关代码写入任何logcat – Apurva 2015-02-23 16:51:02

回答

0

这可能与修补KITKAT中修补的fragment injection vulnerability有关。如果您从KITKAT开始运行targetSdkVersion的应用程序,则当SettingsActivity尝试启动PreferenceFragment时将引发异常。

您需要覆盖PreferenceActivity.isValidFragment()方法。对于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()); 
} 

相关计算器后: isValidFragment Android API 19