本文介绍了使用2.X的API,也将在1.x的运行Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序中,我想用多点触控。不过,我并不想完全离开了那些仍在运行的1.x的OS手机。如何编程的应用程序,让您可以使用2.x的多点触控的API(或任何其他更高级别的API为此事),并仍然允许它优雅的1.x的系统降低。如果您在Eclipse中创建的1.x的一个项目,你能甚至还在访问2.X的API?
基本上我希望它在市场上出现,并在所有1.6及更高版本的手机工作,并只允许进入更高层次的功能,如果有的话。

I'm working on an Android app in which I would like to use multi-touch. However, I do not want to completely leave out those still running a 1.x OS phone. How do you program the app so that you can use the 2.x multi-touch APIs (or any other higher level API for that matter) and still allow it to gracefully degrade on 1.x systems. If you create a project in Eclipse for 1.x can you even still access the 2.x APIs?Basically I want it to show up in the marketplace and work on all 1.6 and higher phones and just allow access to the higher level functionality if available.

此外,如果任何人都可以点我在1.x设备与使用2.x设备数量的任何数据,这将是极大的AP preciated。

Also, if anyone can point me to any data on the number of 1.x devices vs. 2.x devices in use, it would be greatly appreciated.

推荐答案

下面是我如何使用AccountManager的2 *,但有一个备用的1 *地方是不可用的。

Here is how I use the AccountManager on 2.* but have a fallback on 1.* where it isn't available.

我建立的2.1 SDK,但我的清单状态

I build with the 2.1 SDK, but my Manifest states

<uses-sdk android:minSdkVersion="3" />

这确实允许应用程序向上1.5设备上运行。

This does allow the app to run on 1.5 devices upwards.

我限制我使用android.accounts.AccountManager到一个包装类,我把它叫做UserEmailFetcher。

I restrict my use of android.accounts.AccountManager to a wrapper class, I called it UserEmailFetcher.

有将有可能使用这个类上2 *设备。但是在早期设备上java.lang.VerifyError将触发第一次这个类是在code遇到过。这是我抓住,并执行一些回退操作。

It will be possible to use this class on 2.* devices. However on earlier devices a java.lang.VerifyError will fire the first time this class is encountered in the code. This I catch, and perform some fallback action.

String name;
try {
   name = UserEmailFetcher.getEmail(this);
} catch (VerifyError e) {
   // Happens if the AccountManager is not available (e.g. 1.x)
}

希望有所帮助。

这篇关于使用2.X的API,也将在1.x的运行Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:17