I’ve been looking all over for a specific example of this and couldn’t find it online anywhere.
What I want to do is: From my app click a button and move to the Live Wallpaper preview of my apps live wallpaper, so the user can choose to activate it.
Now of what I’ve read online, I’m to use WallpaperManager’s ACTION_CHANGE_LIVE_WALLPAPER with EXTRA_LIVE_WALLPAPER_COMPONENT pointing to my LiveWallpapers ComponentName.
Here’s my code of what I have so far. Anybody know what I’m doing wrong? As of now I click the button and nothing happens… (I logged it and it’s actually reaching this code).
Intent i = new Intent();
i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, "com.example.myapp.livewallpaper.LiveWallpaperService");
startActivity(i);
If you need any more info that I forgot to post let me know.
*I am also aware this is API 16+, this is just my case for when the phone is API 16+
I couldn’t find an example either. The first thing I noticed was that the
EXTRA_LIVE_WALLPAPER_COMPONENTdoesn’t require a String, but aComponentName. My first cut withComponentNamelooked like this:That didn’t cut it, so I dug into the Android source code and found the following in
LiveWallpaperChange.java:A little debugging with the above chunk, and this is my final form…
The key was in the second parameter to
ComponentName.Technically, my final form supports a hierarchy of the new method first, followed by the old, followed by the Nook Tablet/Nook Color specific intent: