为什么奇巧需要使用isValidFragment的?(Why does Kit Kat require the use of the isValidFragment?)

问 题

Ever since KitKat was released, I've noticed a whole bunch of my apps updating with "Fixing a crash in Kit Kat". Recently when I released my own app, I figured out the likely source of that is the new "isValidFragment" requirement for using preference activities. I haven't been able to get anyone, however, to explain why this new class is suddenly needed to validate fragments. Can anyone offer me an explanation of why this is required?

自从奇巧发布后,我发现了一大堆我的应用程序使用“修复崩溃奇巧”更新。最近,当我发布我自己的应用程序时,我想通了,我发现可能的来源是使用preference activities的新要求“isValidFragment”。然而没有人能给我解释为什么这个新类是突然需要验证片段。谁可以给我解释为什么需要这个?

解决方案

Subclasses should override this method and verify that the given fragment is a valid type to be attached to this activity. The default implementation returns true for apps built for android:targetSdkVersion older than KITKAT. For later versions, it will throw an exception.

子类应覆盖此方法,并验证给定的fragment是一个有效的类型附加到这个活动。对于targetSdkVersion在KITKAT之前的Android默认返回true。对于以后的版本,它会抛出异常。

A New Vulnerability in the Android Framework: Fragment Injection
We have recently disclosed a new vulnerability to the Android Security Team. The vulnerability affected many apps, including Settings (the one that is found on every Android device), Gmail, Google Now, DropBox and Evernote. To be more accurate, any App which extended the PreferenceActivity class using an exported activity was automatically vulnerable. A patch has been provided in Android KitKat. If you wondered why your code is now broken, it is due to the Android KitKat patch which requires applications to override the new method, PreferenceActivity.isValidFragment, which has been added to the Android Framework.

在Android框架的新漏洞:片段注入 
  我们最近披露的一个新漏洞到Android安全团队。这个安全漏洞影响到许多应用程序,包括设置(每个Android设备上都能找到),Gmail,Google Now,DropBox 和Evernote。为了更准确,任何使用exported activity扩展PreferenceActivity类的应用程序自动易受攻击。补丁已经在Android的奇巧被提供。如果你想知道为什么你的code现在已经坏了,这是由于Android 奇巧的补丁需要应用到覆盖新方法,preferenceActivity.isValidFragment,已加入到Android Framework

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值