Question

Trying to code a simple Live wallpaper for android. I'm having trouble finding out how to capture the screen size at initialization.

Any thoughts on how I might can accomplish this?

Thanks.

Was it helpful?

Solution

onSurfaceChanged provides width and height as part of its parameters. When this method is called during initialization you can grab the values and save them to method variables like mWidth and mHeight. Then you'll have them anywhere, at anytime to use in your code.

Make note that this method is called AFTER onCreate and onSurfaceCreated, so anything that needs width and/or height will have to wait until onSurfaceChanged gets fired.

Check this sample by Google for a clearer picture: http://developer.android.com/resources/samples/CubeLiveWallpaper/src/com/example/android/livecubes/cube1/CubeWallpaper1.html

OTHER TIPS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top