0

目前我正在尝试在我的应用程序中添加一个偏好活动,但发现我无法让它工作。每次,我都尝试启动首选项活动,但它在显示任何内容之前就崩溃了。

这是清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="keysquare.android"
      android:versionCode="1"
      android:versionName="0.9">
    <application android:icon="@drawable/icon" android:label="@string/ime_name" android:debuggable="true">
        <service android:name="KeysquareAndroid" android:permission="android.permission.BIND_INPUT_METHOD">
            <intent-filter>
                <action android:name="android.view.InputMethod" />
            </intent-filter>
            <meta-data android:name="android.view.im" android:resource="@xml/method" />
        </service>

        <activity android:label="KeysquareAndroidSettings" android:name="KeysquareAndroidSettings" android:exported="true" android:enabled="true"></activity>

    </application>
    <uses-sdk android:minSdkVersion="3" />


</manifest> 

还有偏好 xml,我已尽力将其修剪下来。

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


</PreferenceScreen>

最后是偏好活动课,在我看来也很正常......

package keysquare.android;

import android.os.Bundle;
import android.preference.PreferenceActivity;

public class KeysquareAndroidSettings extends PreferenceActivity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);

    }
}

如果有人可以提供帮助,请提前致谢。

让诺

4

1 回答 1

0

谢谢马蒂亚斯。

终于问题解决了。看来我不应该从服务中调用活动。此外,在 method.xml 中,我应该引用一个完整的包而不是使用本地引用。

让诺

于 2010-06-30T06:39:20.107 回答