2

I decided to create a custom keyboard for my application. I know that this is not the best idea, since it's hurting the user friendliness, that's why I will just make it optional in Preferences.

After having it all done in a class public class CustomKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener. I struggle to add it as a softInputMethod. I tried with the InputMethodManager but I get incompatible types when casting it.

I found that I can get it w/o the Service but it is highly unrecommended and I would need a whole new implementation.

Ideally, I would use it for the EditText command line in the app. So a direct binding to it would also do the job.

After hiding the system input method, how to make this input service the default one?

Thanks.



P.S. If there is an obvious easy way to do this, I am sorry, but I just made the transition to Android and I am still learning.

Dimitar
  • 4,402
  • 4
  • 31
  • 47

2 Answers2

1

Use android:inputMethod on the text field you want to change the input method on. See https://developer.android.com/reference/android/widget/TextView.html#attr_android:inputMethod

You cannot set a default input method for the entire device, but you can override it on a field by field basis in your app. Adding a default input method for your Activity or Application's theme should override it for all text views in your app.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • @m0skit0 Definitely works, you've done something wrong. Feel free to post your code as a question. – Gabe Sechan Sep 11 '18 at 18:01
  • First, android:inputMethod is shown as deprecated wherever I put it. If I assign it to my InputMethodService child class name in application or activity tags in the manifest, it is ignored (both relative and canonical names). If I put it in the view, it throws a ClassNotFoundException when inflating the view. – m0skit0 Sep 11 '18 at 20:34
  • If you need help, ask a question and include all relevant code. It's not going to be debugged in comments – Gabe Sechan Sep 11 '18 at 20:37
0

I think you can just make a custom view that prevents default keyboard(the default InputMethodService such as SamsungKeyboard) popping up and show your own. Which you place all the keys and interact with onTouchListener.

Or if you are trying to make your own Keyboard Application such as SwiftKey, You might want to read this:(https://developer.android.com/guide/topics/text/creating-input-method.html)

luopleming
  • 28
  • 1
  • 9