问题
Nothing is posted in logcat.Application just stops working. Here is my code form manifest
<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>
Below is my settings Activity code
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);
}
My xml file for settings is
<?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>
What is wrong here.I am unable to come up with anything because nothing is shown in logcat about any error.
回答1:
it occur many time with me also, i know this problem and solution well,i think you just forgot to change your package name in you xml folder wallpaper.xml file, just check following you got your answeres.
i think you wallpaper.xml // you understand your file name whatever you take
<?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" />
like,
<?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" />
来源:https://stackoverflow.com/questions/24103181/application-is-crashing-when-i-click-settings-option-in-live-wallpaper