Can I make a screenshot of a homescreen from my application propgammatically?
I develop an application, which allows user to choose wallpaper from gallery and set it as a device wallpaper. I want to make a preview for each picture in gallery as it is a real wallpaper. The preview is a screenshot of a homescreen with all widgets and icons and selected pi开发者_如何学运维cture as a device wallpaper.
I think about two variants:
1) Change current wallpaper to a picture, which user looks. Then make a screenshot of a homescreen with this wallpaper and all widgets and icons. Then show this screenshot to user and put real wallpaper back.
2) Get all widgets and icons position, draw it on a picture, which user looks.
I don't know how to implement any of this variants. If you have any idea, pleace help me.
make one similar to a real desktop (fake desktop) with your own data (not user icons or widgets), at least you can show him an desktop to compare
There is no screenshot support in the Android SDK. And, you have no way to determine "widgets and icons position". Hence, neither of what you want to do will be possible.
You need root access to capture screenshots without debugging tools, on most devices. I recommend making a home screen activity that draws the current layout, but this depends on whether the user's home launcher of choice allows you to access the current layout. It may also be helpful to register your activity/app as a wallpaper selector (shows up in the list when you press 'Wallpaper' from the menu on most home screens) - QuickPic does this, I think it's part of the API somewhere.
精彩评论