无法启动我的偏好活动
目前我正在尝试将首选项活动添加到我的应用程序中 但发现我无法让它发挥作用。 每次,我都尝试启动偏好活动,但它在显示任何内容之前就崩溃了。
这是清单
<?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);
}
}
如果有人可以提供帮助,请提前致谢。
让诺
Currently I am trying to add a preference activity into my application
but found out that I couldn't make it works.
Every time, I tried to start the preference activity but it just crash before showing anything.
Here is the manifest
<?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>
And the preference xml, which I have tried my best to trim it down.
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
</PreferenceScreen>
And finally the preference activity class, which also looks normal to me...
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);
}
}
Thanks in advance if anyone can help.
Jeanno
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢马蒂亚斯。
最后问题解决了。
看来我不应该从服务中调用活动。
另外,在 method.xml 中,我应该引用完整的包,而不是使用
本地参考。
让诺
Thanks Mathias.
Finally the problem was solved.
It seems that I shouldn't call activities from a service.
Also, in the method.xml, I should reference to a full package instead of using a
local reference.
Jeanno