4

I'm working on a Live Wallpaper and I would like to keep it always in portrait mode. I know it's possible for an Activity to declare the orientation in the Manifest, but I can't find a way to do the same with a live wallpaper service. Is it possible somehow to tell the Wallpaper Engine to swap the x and y axis in the rendering process or something similar, because I have no idea anymore.

meatboy
  • 131
  • 1
  • 4

2 Answers2

2

Use the following method to check for orientation changes

public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)

If width is greater than height you know that the orientation changed to landscape.

Be sure that you now treat x as y and y as x. Same goes for width and height.

Al0x
  • 917
  • 2
  • 13
  • 30
  • Isn't there any way to just lock the wallpaper service from rotating? I don't have direct access to the Bitmaps, I'm just using an ApplicationListener which actually renders everything and it would be very tedious to rewrite everything so that it can manage landscape – meatboy Sep 05 '13 at 14:44
  • 1
    I cannot think of any other way to achieve this – Al0x Sep 05 '13 at 22:17
0

You have handle the orientation change for live wallpaper. you can't fix the orientation.

Bhavik Tikudiya
  • 103
  • 1
  • 7