一、还是像普通的android动态壁纸一样,创建一个没有activity的安卓工程TestLibGDXWallpaper
二、
AndroidManifest.xml配置
- <application
- android:icon=”@drawable/icon”
- android:label=”@string/app_name” >
- <service
- android:name=”.MyLiveWallpaper”
- android:icon=”@drawable/icon”
- android:label=”@string/app_name”
- android:permission=”android.permission.BIND_WALLPAPER” >
- <intent-filter>
- <action android:name=”android.service.wallpaper.WallpaperService” />
- </intent-filter>
- <meta-data
- android:name=”android.service.wallpaper”
- android:resource=”@xml/livewallpaper” />
- </service>
- </application>
复制代码
1、权限
android:permission=”android.permission.BIND_WALLPAPER”,否则该壁纸只能预览,不能被实际应用
2、
添加声明
android:name=”android.service.wallpaper.WallpaperService”以便系统识别
3、
android:name=”.MyLiveWallpaper”为动态壁纸的service类
4、meta-data部分为动态壁纸的配置信息xml/livewallpaper需要手动创建res/xml/livewallpaper.xml
三 、
livewallpaper.xml
- <?xml version=”1.0″ encoding=”utf-8″?>
- <wallpaper xmlns:android=”http://schemas.android.com/apk/res/android”
- android:thumbnail=”@drawable/icon” />
复制代码
只是配置其图标(没有“设置”项)
四、jar包和.so库导入
将从官方下载下来的压缩包中的gdx.jar和gdx-backend-android.jar包复制到工程libs目录下(再build path 步骤省略),将相关.so库复制到libs目录下!
