I've been working on a fairly simple keyboard application and I wanted to add a few settings to it. I've been through several tutorials and more reference pages than I can count over the last week and I was hoping someone here might be able/willing to catch my mistake(s).
My app builds without error (only a single warning about the use of a depreciated function, ) but the preferences activity just will not launch from the language and input settings menu.
Heres what I have so far
Contents of the application tag on AndroidManifest.xml
<service
android:name=".SimpleIME"
android:label="@string/app_name"
android:permission="android.permission.BIND_INPUT_METHOD">
<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
</service>
<activity
android:name=".keyboardPrefsActivity"
android:label="@string/title_activity_keyboard_prefs">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
method.xml
<?xml version="1.0" encoding="utf-8"?>
<input-method xmlns:android="http://schemas.android.com/apk/res/android">
<subtype
android:label="@string/subtype_en_US"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard"
android:settingsActivity="com.dev.tompk.learnmorsekeyboard.keyboardPrefsActivity"/>
</input-method>
preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="lmk_settings"
android:title="Learn Morse Keyboard Settings">
<EditTextPreference
android:key="MorsePulseRate"
android:title="@string/morse_pulse_rate_pref_title"
android:summary="@string/morse_pulse_rate_pref_summary"
android:numeric="integer"
android:maxLength="3"
android:defaultValue="100"
/>
</PreferenceScreen>
keyboardPrefsActivity.java
package com.dev.tompk.learnmorsekeyboard;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
public class keyboardPrefsActivity extends PreferenceActivity {
private EditTextPreference morsePulseRate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
morsePulseRate = (EditTextPreference)findPreference("MorsePulseRate");
}
}
At this point I don't need anything fancy with headers or breaking it out into smaller fragments (unless that's necessary to make it work). My current aim is to have a list of 2 maybe 3 settings each taking an integer (string will do if necessary since it can be converted or replaced with a default value)
I realize my code is a bit messy with all of the different things I've tried, but any suggestions would be greatly appreciated.
Thanks in advance.
<activity
android:name=".SettingsActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
I realize that this answer might be a bit late for you, but someone might want the answer to this. Try adding an 'android:theme=""' to the settings activity like you would a normal activity, that solved the problem for me.
Also you can try putting the 'android:settingsActivity' inside the input-method tag rather than under the subtype tag.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.