Access Livewallpaper selection or Livewallpaper preview from a button

uswin4224

Member
Licensed User
Longtime User
guys, I have a question about live-wallpaper.

How can I access live-wallpaper selection screen and the wallpaper preview itself from a button click ? can you guys point me the direction ?

Basically I try to create a main activity which has a button that when I click the button it will go to live-wallpaper selection or my own wallpaper preview (which has set wallpaper and setting button)

really appreciated it if you guys has any input on this.
 

uswin4224

Member
Licensed User
Longtime User
You can show the live wallpaper picker with this intent"
B4X:
Dim i As Intent
i.Initialize("android.intent.action.SET_WALLPAPER", "")
i.SetComponent("com.android.wallpaper.livepicker/.LiveWallpaperActivity") 'consider removing this line as it might not work on all devices.
StartActivity(i)

Hi Erel, thanks a lot for your solution, yes it is indeed work. I also found another solution to directly go to live wallpaper selection using this

B4X:
Sub button1_click
Dim Intent1 As Intent
Intent1.Initialize("android.service.wallpaper.LIVE_WALLPAPER_CHOOSER","") 
StartActivity(Intent1)
End Sub

Now for the next question, how can I set intent to directly preview my livewallpaper ? I use this

B4X:
android.service.wallpaper.CHANGE_LIVE_WALLPAPER
but it throw error and it said I cannot find my livewallpaper. How can I do this ?
Thanks.
 
Upvote 0

uswin4224

Member
Licensed User
Longtime User
AFAIK it is not possible.

hmm, when i look at android doc for wallpaper manager

WallpaperManager | Android Developers

,there is this info function

B4X:
public static final String ACTION_CHANGE_LIVE_WALLPAPER
Since: API Level 16

Directly launch live wallpaper preview, allowing the user to immediately confirm to switch to a specific live wallpaper. You must specify EXTRA_LIVE_WALLPAPER_COMPONENT with the ComponentName of a live wallpaper component that is to be shown.
Constant Value: "android.service.wallpaper.CHANGE_LIVE_WALLPAPER"

and this info function

B4X:
public static final String EXTRA_LIVE_WALLPAPER_COMPONENT
Since: API Level 16

Extra in ACTION_CHANGE_LIVE_WALLPAPER that specifies the ComponentName of a live wallpaper that should be shown as a preview, for the user to confirm.
Constant Value: "android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT"

Is this possible using this function ? by setting the extra component with the name of our livewallpaper and then set it into the intent. If this is possible, any idea how to implement this ?

Thanks before
 
Upvote 0

uswin4224

Member
Licensed User
Longtime User
You are correct. However this is a new API which will only work with Android 4.1 or above. If this is relevant I can help you with building the intent.

Aaah I see. yes. the API level is 16 which is for jelly bean+, I believe most of android device has not updated to that version that much yet. I probably will not use this yet,

But I still curious about this Erel, could you show me how to build the intent ? just in case I might use something like this in the future ?

Many thanks Erel.
 
Upvote 0

uswin4224

Member
Licensed User
Longtime User
Something like:
B4X:
Dim i As Intent
i.Initialize("android.service.wallpaper.CHANGE_LIVE_WALLPAPER", "")
i.PutExtra("android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT", "your.package/.youractivity")

Thanks Erel for the snippet.
I will try this at home. :sign0188:
 
Upvote 0
Top