Err*_*454 33
现在有两种方法可以实现这一点,因为Jelly Bean提供了一种直接设置动态壁纸的方法.此样板代码将选择可用的最佳方法.
Intent i = new Intent();
if(Build.VERSION.SDK_INT > 15){
i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
String p = HypercaneWallpaperService.class.getPackage().getName();
String c = HypercaneWallpaperService.class.getCanonicalName();
i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(p, c));
}
else{
i.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
}
getActivity().startActivityForResult(i, 0);
Run Code Online (Sandbox Code Playgroud)
Jos*_*osh 26
好吧,就这样我就停止了过时的回答.请参阅下面的错误454的答案,以获得更强大的解决方案,该解决方案将用户直接发送到Jelly Bean和up设备上的壁纸预览屏幕.
========================================
以下是启动壁纸选择器的方法,用户可以从中选择壁纸.吐司只是向用户解释发生了什么的一种方式.
Toast toast = Toast.makeText(this, "Choose '<WALLPAPER NAME>' from the list to start the Live Wallpaper.",Toast.LENGTH_LONG);
toast.show();
Intent intent = new Intent();
intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)