首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

经过代码设置live wall paper

2012-07-03 
通过代码设置live wall paper1.The code is:private WallpaperManager mWallpaperManager WallpaperMana

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

热点排行