それでは、必要な設定ファイル(XML)を1つずつ説明していきます。
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.livewallpaper">
<application
android:label="@string/wallpaper_name"
android:icon="@drawable/thumbnail">
<service
android:name=".FireWallpaperService"
android:label="@string/wallpaper_name"
android:permission="android.permission.BIND_WALLPAPER"> <!--【1】-->
<intent-filter>
<action
android:name="android.service.wallpaper.WallpaperService" /> <!--【2】-->
</intent-filter>
<meta-data <!--【3】-->
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>
<activity <!--【4】-->
android:label="@string/wallpaper_settings"
android:name=".FireWallpaperSettings"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true">
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?> <wallpaper <!--【5】--> xmlns:android="http://schemas.android.com/apk/res/android" android:thumbnail="@drawable/thumbnail" <!--【6】--> android:description="@string/description" <!--【7】--> android:settingsActivity="com.example.android.livewallpaper.FireWallpaperSettings" /> <!--【8】-->
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen <!--【9】-->
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings">
<ListPreference
android:key="@string/preference_key" <!--【10】-->
android:title="@string/settings_title" <!--【11】-->
android:summary="@string/settings_summary" <!--【12】-->
android:entries="@array/entries" <!--【13】-->
android:entryValues="@array/values" /> <!--【14】-->
</PreferenceScreen>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!--【15】-->
<string-array name="entries"> <!--【16】-->
<item>Strong</item>
<item>Middle</item>
<item>Low</item>
</string-array>
<string-array name="values"> <!--【17】-->
<item>60</item>
<item>120</item>
<item>150</item>
</string-array>
</resources>
設定画面は下記のようなイメージです。
また、設定項目は、壁紙選択のトップ画面からも呼び出しできるようになります。
次ページでは、Live Wallpaperの実装を見てみましょう。
Copyright © ITmedia, Inc. All Rights Reserved.