[英]Application is crashing when i click settings option in live wallpaper
logcat中什么都沒有發布。應用程序停止工作。 這是我的代碼清單
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name =".LiveWallpaperAndroid"
android:label = "@string/app_name"
android:icon = "@drawable/ic_launcher"
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>
<activity android:label="@string/livewallpaper_settings"
android:name=".LiveWallpaperSettings"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true"
android:icon = "@drawable/ic_launcher">
</activity>
</application>
以下是我的設置活動代碼
public class LiveWallpaperSettings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener
{
@Override
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
getPreferenceManager().setSharedPreferencesName(LiveWallpaperScreen.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.football);
getPreferenceManager().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
我的xml設置文件是
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/livewallpaper_settings"
android:key="livewallpaper_settings">
<ListPreference
android:key="livewallpaper_testpattern"
android:title="@string/livewallpaper_settings_title"
android:summary="@string/livewallpaper_settings_summary"
android:entries="@array/livewallpaper_testpattern_names"
android:entryValues="@array/livewallpaper_testpattern_prefix"/>
<CheckBoxPreference android:key="livewallpaper_movement"
android:summary="@string/livewallpaper_movement_summary"
android:title="@string/livewallpaper_movement_title"
android:summaryOn="Moving test pattern"
android:summaryOff="Still test pattern"/>
</PreferenceScreen>
這是怎么回事,我無法提出任何建議,因為logcat中未顯示任何錯誤。
它也和我在一起發生了很多次,我也很清楚這個問題和解決方案,我想您只是忘記了在xml文件夾wallpaper.xml文件中更改軟件包名稱,所以請檢查以下內容是否正確。
我認為您是wallpaper.xml //您無論了解什么都可以理解文件名
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="YourAllPAckageName.YourSettingActivity"
android:thumbnail="@drawable/ic_launcher" />
喜歡,
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.wallpaperexample.WallpaperSettingsActiity"
android:thumbnail="@drawable/ic_launcher" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.