显示动态壁纸在1.6目标应用程序通过检测,如果它是一个2.1的设备? [英] Showing Live Wallpaper in a 1.6 target app by detecting if it's a 2.1 device?

查看:264
本文介绍了显示动态壁纸在1.6目标应用程序通过检测,如果它是一个2.1的设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建与目标SDK 1.6的Andr​​oid应用程序,所以它会在1.6的设备和更高版本上运行。我们希望支持动态壁纸,我们只知道是2.1+。有没有建立一个应用程序1.6 SDK作为目标,但如果发现它运行的设备是2.1,只有在那种情况下调用动态壁纸API的方式。

We're building an Android app with target SDK 1.6, so it will run on 1.6 devices and higher. We'd like to support Live Wallpapers, which we know is 2.1+ only. Is there a way to build one app with 1.6 SDK as the target, but detect if the device it's running on is 2.1, and only in that scenario call the live wallpaper API.

我们正在努力,以避免建立一个独立的1.6和2.1版本,并希望能够支持动态壁纸的只有2.1设备。所以要在清1个应用,可以支持1.6及更高版本,并支持动态壁纸为2.1的设备。

We're trying to avoid having to build a separate 1.6 and 2.1 versions, and would like to be able to support Live Wallpapers for only 2.1 devices. So to be clear- 1 app, that can support 1.6 and higher, and support live wallpapers for 2.1 devices.

这样的方法吗?

推荐答案

也许吧。我还没有与现场壁纸的工作,但这里是我如何使用AccountManager的2 *,但有一个备用的1 *地方是不可用的。

Maybe. I haven't worked with Live Wallpapers, but 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)
}

希望有所帮助。

这篇关于显示动态壁纸在1.6目标应用程序通过检测,如果它是一个2.1的设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆