通过代码设置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();
                }


2. And you must add the following permissions in your manifest:
 
 <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" />


3. You must push your apk to /system/app. If not, it can’t work.

你可能感兴趣的:(android)