call Live wallpaper within application

痴心易碎 提交于 2019-12-11 13:57:26

问题


I am trying to implement following thing in android 2.x.

In my application i want to allow the user to create the custom live wallpaper kind of thing where user chooses few images and then those image will rotate in a typical fashion and after that user will be able to set it all the view as a live wallpaper within the application only.

i have successfully implemented the selection of images and its rotation now i don't know how to set live wallpaper within the application. i have tried implementing Live Wallpaper chooser but it is used to access already installed live wallpaper. but what about the dynamically created live wallpaper?

Even i tried to call it using following line of code

intent.setClassName("com.android.wallpaper.livepicker", "com.android.wallpaper.livepicker.LiveWallpaperPreview");

But it is giving me an error

java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview } from ProcessRecord{43f94a38 29784:com.vb.ui/10038} (pid=29784, uid=10038) requires null

There might be few ways but m not sure about it

is it possible to install live wallpaper apk programmatically so that once the live wallpaper is created it is being installed by the application ?

if live wallpapers are stored in some place then we can store user created live wallpaper at that place so when live wallpaper chooser is being selected we can see the live wallpaper in the list


回答1:


Maybe you should open this custom picking activity from within the standard "Settings" button a user sees when choosing your live wallpaper.

  1. User goes into standard live wallpaper chooser, sees a list of installed LWPs, picks yours.
  2. User sees your default implementation, chooses "Settings" button.
  3. You show a list of settings, one of which is a PreferenceScreen named "Pick Images."
  4. Assign an onClickListener to that preference item which launches your custom image picking activity.


来源:https://stackoverflow.com/questions/4365277/call-live-wallpaper-within-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!