I'm trying to develop android app And I want to allow user to choose background of app from live wallpapers.
Now, How I can get Live Wallpapers from device?
I want to get all live wallpapers from device, Can I do it?
I'm trying to develop android app And I want to allow user to choose background of app from live wallpapers.
Now, How I can get Live Wallpapers from device?
I want to get all live wallpapers from device, Can I do it?
You can get available ResolveInfo list of all live wallpapers in the device:
public List<ResolveInfo> GET_ALL_LIVE_WALLPAPERS ()
{
PackageManager m_package_manager = getPackageManager();
List<ResolveInfo> available_wallpapers_list =
m_package_manager.queryIntentServices(
new Intent(WallpaperService.SERVICE_INTERFACE),
PackageManager.GET_META_DATA);
for (int i = 0; i < available_wallpapers_list.size(); i++) {
Log.i("TEST", " " + available_wallpapers_list.get(i).toString());
}
return available_wallpapers_list;
}
available_wallpapers_list
will contain the amount of ResolveInfo same as the amount of live wallpapers in the device. Then choose any of them in the list by creating a new WallpaperInfo of desired one:
private void CHOOSE_LIVE_WALLPAPER (List<ResolveInfo> available_wallpapers_list)
{
WallpaperInfo info;
int index = 0;
try {
info = new WallpaperInfo(this, available_wallpapers_list.get(index));
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
ComponentName component = info.getComponent();
Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, component);
startActivityForResult(intent, 155);
}
If you just want to be cooler and show a live wallpaper selection screen, use:
Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
startActivityForResult(intent, 155);
Lastly you can call adb shell am command for 4.3+ devices;
adb shell am start -n com.android.wallpaper.livepicker/.LiveWallpaperActivity
by using:
Runtime.getRuntime().exec("am start -n com.android.wallpaper.livepicker/.LiveWallpaperActivity");
Cheers.
Intent intent = new Intent();
intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
startActivity(intent);