I have an Android application with version 1.6 I take the wallpaper and show it on my application. (I do that programatically by calling getWallpaper() on the Activity)
When this is installed on a 2.1 phone, that has live wallpaper, the live wallpaper is not returned by getWallpaper() , because it just returns a Drawable, and live wallpaper probably is another thing.
So the question is, is it possible to show a live wallpaper on the background of a 1.6 application? How?
Thanks
========================================================================================
So far I haven't found a solution for this. I am adding this to better understand the question
To be clear: The app is w开发者_JAVA百科ritten for 1.6 so it will work on all 1.6 and higher. The question is: can we write an app with 1.6 as the target, but support live wallpapers if its being run on a 2.1 device??
Thanks
I found a solution:
1) With android.os.Build.VERSION.SDK_INT check what version the phone has. 2) make if/else calls, so for each version you can call the desired method. In this case:
if (android.os.Build.VERSION.SDK_INT >= 7) {
this.setTheme(android.R.style.Theme_Wallpaper);
}
else
{
//something else
}
3) Build the app using 2.1. and set in the manifest uses-sdk android:minSdkVersion="4" so it also runs on 1.6
4) make sure it works on both phones 1.6 and 2.1, because since you have calls to both SDKs, make sure you dont call methods of 2.1 when you are running 1.6 and the other way around.
Thanks for the help
Live wallpapers were added in 2.1, so it simply does not make sense to try to show a live wallpaper on a 1.6 (or 2.0) device.
In 2.0 the Theme.Wallpaper theme style was added, which as the new official way to put an activity (or window) on top of the system's wallpaper (live or not). Of course, since this appeared in 2.0, you also can not use this in 1.6.
Prior to 2.0, the only way to display on top of the system wallpaper was to use getWallpaper() to retrieve the static wallpaper image, and take care of drawing it yourself in your UI. This of course can not support live wallpapers.
If you want to have an app that shows in the wallpaper on both pre-2.0 and 2.0 and later versions of the platform, you will need to check the API version in android.os.Build, and adjust your behavior appropriately: when initializing your activity, if 2.0 or later use setTheme to choose the wallpaper theme; otherwise, get the drawable and make it the background of your UI. When using the wallpaper theme, you need to make sure your UI does not draw an opaque background on top of it and cover it up. You may also want to try setting your activity's theme to Theme.Translucent, to get better behavior on 2.0 or later (where ideally you would use Theme.Wallpaper which also gives you the proper animations).
Actually, you could conceivable use versioned resouurces to make your own theme that adjusts appropriately depending on the platform version (either a wallpaper or a traditional theme). I have never tried to do this, though.
Have you tried using Theme.Wallpaper
as your Activity's theme? That sets the phone's wallpaper as the background of the activity, and works with Live Wallpapers.
精彩评论