Showing Live Wallpaper in a 1.6 target app by detecting if it's a 2.1 device?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 07:22:17

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.

I build with the 2.1 SDK, but my Manifest states

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

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

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

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)
}

Hope that helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!