在 Daydream 屏幕保护程序中使用首选项屏幕

using preference screen in daydream screensaver

我想从屏幕保护程序设置中启动首选项屏幕,但是当我尝试应用时,应用程序正在强制关闭。

我遇到错误

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.anuja.ddtrial4/com.example.abc.ddtrial4.preferenceclass}; have you declared this activity in your AndroidManifest.xml?

这是我的代码

setting.xml

<?xml version="1.0" encoding="utf-8"?>
<dream xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.example.abc.ddtrial4/.preferenceclass"/>

preference.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<SwitchPreference
    android:defaultValue="false"
    android:icon="@drawable/analog1"
    android:key="switch_preference_1"
    android:switchTextOff="Digital"
    android:switchTextOn="Analog" />
</PreferenceScreen>

preferenceclass.java

public class preferenceclass extends PreferenceActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preference);


}
}

ActivityNotFoundException: Unable to find explicit activity class {com.example.anuja.ddtrial4/com.example.abc.ddtrial4.preferenceclass};

确保您在 Manifest 部分添加了此内容

PreferenceActivity.

This is the base class for an activity to show a hierarchy of preferences to the user .

 <activity  android:name=".preferenceclass"
  android:theme="@android:style/Theme.Black.NoTitleBar">

 </activity>