Wow that sounds like you are making it way too complicated, and way too fragile. A few comments:
On Fri, Jul 15, 2011 at 1:08 PM, Hal Harrison <closeenough.bac...@gmail.com>wrote: > 1. Upon exit from preview mode the system will always show the panel > of icons and widgets last showing before preview mode. > You should not be doing special things "upon exit of preview mode." Don't assume there is some flow that will happen there. An engine will be created, and told whether or not it is in preview mode. That is it. Don't make dependencies between these. > In WallpaperService.onCreate() I get wallpaper width from > WallpaperManager.getDrawable() and getBitmap() and getWidth(), > and > You have at this point loaded a Drawable for the current static wallpaper... but there is no up-to-date static wallpaper, because you have just replaced it with your own wallpaper. Your wallpaper should absolutely positively not be trying to load the current static wallpaper here. There are no guarantees that this is up-to-date or even valid. There are already APIs on the engine to get the desired size for the wallpaper: Engine.getDesiredMinimumWidth() and Engine.getDesiredMinimumHeight(). Also be sure to handle onDesiredSizeChanged(). 2. device screen width in pixels = wallpaper width / 2; > However many homescreens there are, > No you can not assume that. The current launcher can set the desired wallpaper width to whatever it wants. > 3. offset to center panel of wallpaper = the negative of (device > screen width / 2); > You can get the screen size with Service.getResources().getDisplayMetrics().width/heightPixels. To compute your center position, it is just standard centering if a smaller container (display size) in a larger container (desired wallpaper size): (getDesiredMinimumWidth()-widthPixels)/2. > Therefore, during preview mode I show this center panel. Upon exit > from preview mode I get my first onOffsetsChanged() callback and can > calculate the real number of home screens and manage my background > accordingly. > In preview mode I would say you should just show a preview. Don't even try to show multiple panes, it doesn't make sense there. This is why we tell the engine it is in this special preview mode. Perhaps in the future some live wallpaper applications would be better > served if the system exposed additional information it obviously has: > (a) during onCreate(), some direct way to get device screen size and > number of home screens, > You can already get the display size through DisplayMetrics. You will not get the "number of home screens." Again, that concept doesn't strongly exist. > (b) upon entry to preview mode, some way to get which home screen was > last showing > No just show a preview. > (c) upon exit from preview mode, some way to set which home screen (of > icons and widgets) will show next. > No that is up to the application sitting on top of the home screen, and can change as you move between such apps. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en