读书人

经过代码设置live wall paper

发布时间: 2012-07-03 13:37:43 作者: rapoo

通过代码设置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.

读书人网 >移动开发

热点推荐