通过代码设置live wall paper
1.The code is:
private WallpaperManager mWallpaperManager = WallpaperManager.getInstance(this); Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE); intent.setClassName("com.android.wallpaper", "com.android.wallpaper.galaxy.GalaxyWallpaper"); // you can set any live wall paper which you want try { mWallpaperManager.getIWallpaperManager().setWallpaperComponent( intent.getComponent()); } catch (RemoteException e) { e.printStackTrace(); // do nothing } catch (RuntimeException e) { e.printStackTrace(); }
<uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> <uses-permission android:name="android.permission.BIND_WALLPAPER" /> <uses-permission android:name="android.permission.SET_WALLPAPER" />