Google 샘플 코드를 사용하여 소프트 키보드를 만들고 키보드의 키 스타일을 변경할 수있는 설정 환경을 구현하려고합니다. Input 메서드를 호출 할 때 Preference Activity (샘플 코드에서 편집되지 않음) null 포인터 예외가 발생합니다.IME 기본 설정을 시작할 때 Null 포인터 예외
//show settings menu on click of menu key
ImePreferences p = new ImePreferences();
Intent i = p.getIntent();
startActivity(i);
내 ImePreference입니다.
public class ImePreferences extends PreferenceActivity {
/**
* Adds intent extras so fragment opens
*/
@Override
public Intent getIntent() {
final Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, Settings.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// We overwrite the title of the activity, as the default one is "Voice Search".
setTitle(R.string.IME_settings);
}
public static class Settings extends InputMethodSettingsFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
setSubtypeEnablerTitle(R.string.select_language);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.ime_preferences);
}
}
}
은 여기 내 로그는이 서비스로 키보드를 구축 처음 메신저입니다 일어나는 이유
07-09 13:36:29.577: E/AndroidRuntime(19994): FATAL EXCEPTION: main
07-09 13:36:29.577: E/AndroidRuntime(19994): java.lang.NullPointerException
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.content.Intent.<init>(Intent.java:3217)
07-09 13:36:29.577: E/AndroidRuntime(19994): at orsto.board.orstoboardv3.ImePreferences.getIntent(ImePreferences.java:19)
07-09 13:36:29.577: E/AndroidRuntime(19994): at orsto.board.orstoboardv3.Orstoboard.onKey(Orstoboard.java:450)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.inputmethodservice.KeyboardView.detectAndSendKey(KeyboardView.java:824)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.inputmethodservice.KeyboardView.onModifiedTouchEvent(KeyboardView.java:1341)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.inputmethodservice.KeyboardView.onTouchEvent(KeyboardView.java:1204)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.View.dispatchTouchEvent(View.java:5553)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2019)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1754)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2019)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1754)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2019)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1754)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2019)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1754)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2019)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1754)
07-09 13:36:29.577: E/AndroidRuntime(19994): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1930)
07-09 13:36:29.577: E/AndroidRuntime(19994): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1389)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.app.Dialog.dispatchTouchEvent(Dialog.java:738)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.inputmethodservice.SoftInputWindow.dispatchTouchEvent(SoftInputWindow.java:75)
07-09 13:36:29.577: E/AndroidRuntime(19994): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1878)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.View.dispatchPointerEvent(View.java:5733)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3104)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2666)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:900)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2675)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.os.Looper.loop(Looper.java:154)
07-09 13:36:29.577: E/AndroidRuntime(19994): at android.app.ActivityThread.main(ActivityThread.java:4624)
07-09 13:36:29.577: E/AndroidRuntime(19994): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 13:36:29.577: E/AndroidRuntime(19994): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 13:36:29.577: E/AndroidRuntime(19994): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
07-09 13:36:29.577: E/AndroidRuntime(19994): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
07-09 13:36:29.577: E/AndroidRuntime(19994): at dalvik.system.NativeStart.main(Native Method)
어떤 생각이며 나를 난처한 상황에 빠진했다.
덕분에 마크
'new ImePreferences()'할 수 없습니다. 일반적으로 활동을 인스턴스화 할 수 없습니다. – njzk2
붙여 넣은 환경 설정 파일은 getIntent() 메서드를 사용할 수 있도록 활동을 인스턴스화해야하는 샘플 코드에서 변경되지 않았습니다. – MarcD
'getIntent() 메소드를 사용할 수 있도록 액티비티를 인스턴스화해야합니다. ' 자신을 인스턴스화 한 액티비티에는'getIntent'를 사용할 수 없습니다. – njzk2