安卓; 2.1 和 2.2 之间是否有开发人员需要注意的向后兼容性变化?
我已经创建了一些针对 2.2 的应用程序,
我正在考虑投资一台便宜的手机来尝试这些应用程序(到目前为止仅使用模拟器)。我想要的手机运行的是 Android 2.1 版本。
从代码的角度来看,2.1 和 2.2 之间是否存在可能给我带来问题的重大变化?
我知道如果我尝试部署到 1.x 手机,就会出现问题(例如 People/ContractsContact 等),但我看不到任何说明 2.2 应用程序会在 2.1 环境中失败
(我可以尝试更改模拟器目标,但很想从其他拥有实际手机的人那里了解情况)
谢谢
I've created a few applications that have been targetted against 2.2
I'm thinking to invest in a cheap handset to try these out (thus far only used emulator). The handset I want is running verion 2.1 of Android.
From a code point of a view, is there any major changes between 2.1 and 2.2 that could potentially cause me an issue?
I understand there would be issues if I was trying to deploy to a 1.x handset (such as People/ContractsContact etc) but I can't see anything to say a 2.2 app would fail on a 2.1 environment
(I could try to change emulator target, but curious to know from others with actual handsets)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下页面可能对您有用: http://developer.android.com /sdk/api_diff/8/changes.html
您可以交叉检查用于差异列表的所有包和方法。
正如 Juhani 所说,如果您的应用程序使用任何新的 API,那么这意味着您很可能会遇到问题。
Here's the page that might be useful to you: http://developer.android.com/sdk/api_diff/8/changes.html
You can cross-check all your packages and methods used to the differences list.
Like Juhani said, if your app uses any of the new APIs, then that would mean a high possibility of your encountering problems.
如果您不需要 2.2 提供的任何新 API,则可以将您的应用程序定位到 2.1。这样您就可以确保它可以在 2.1 和 2.2 上运行。另一方面,如果您需要一些新的 API,它将无法在 2.1 上正常工作。
您可以在此处查看 2.2 中的新增功能:
http://developer.android.com/sdk/android-2.2.html
You could just target your app to 2.1 if you don't need any of the new APIs provided with 2.2. That way you can be sure that it will run on 2.1 and 2.2. If you, on the other hand, need some of the new APIs it will not work correctly on 2.1.
You can se what's new in 2.2 here:
http://developer.android.com/sdk/android-2.2.html
为了保证兼容性,您应该将目标版本设置为 2.1 并重新编译它以查看失败的原因。如果您使用的是仅限 2.2 的 API,这将向您展示它是什么。然后,如果您确实想使用它,可以将目标版本重置为 2.2,并在 2.1 中为“找不到方法”编写后备行为。
除了记录的 API 之外,对于大多数开发人员来说,最大的区别来自于那些使用通用但不受支持的接口的人。如果您尝试调用日历,您会发现它停止工作,因为旧意图“com.android.calendar/com.android.calendar.LaunchActivity”已被“com.google.android.calendar/com”取代.android.calendar.LaunchActivity”。 (这是针对原生 Android 的。各种手机/硬件供应商都有其他备用应用程序/意图,只是为了让您保持警惕。)
当然,只有当您使用未记录的、不受支持的接口时,这才是一个问题,您不应该这样做正在做。然而,这可能是“被 FroYo 破坏”应用程序的第一大来源。
For guaranteed compatibility, you should just set your target version to 2.1 and recompile it to see what fails. If you are using a 2.2-only API, this will show you what it is. Then, if you really want to use it, you can reset the target version to 2.2 and code up a fallback behavior for "method not found" in 2.1.
Outside of the documented API, the biggest difference for most developers comes for those using a common but unsupported interface. If you are trying to invoke the calendar, you'll find that it stops working because the old intent "com.android.calendar/com.android.calendar.LaunchActivity" has been replaced by "com.google.android.calendar/com.android.calendar.LaunchActivity". (This is for stock android. Various phone/hardware vendors have other alternate apps/intents, just to keep you on your toes.)
Of course, this is only a problem if you are using undocumented, unsupported interfaces, which you shouldn't be doing. However, this has probably been the number one source of "broken by FroYo" apps.