I want to create a generic keyboard like Emoji . I am following this tutorial.
I want the main softkeyboard to work as it is or I mean extends it. Only want to change layout and events on mModeChangeKey clicked when symbols shows.
When mode is changed i want to display my keyboard with emoticons. and just add it as others emoticons do.
Manifest.xml
<service android:name="com.example.keyboardtesting.MyInputMethod"
android:label="@string/app_name"
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>
also added permissions..
first button click
startActivityForResult( new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS), 0);
Second button click
InputMethodManager inputmethodmanager = (InputMethodManager) getSystemService("input_method");
if (inputmethodmanager != null)
{
inputmethodmanager.showInputMethodPicker();
}
Because it is upto the user to select both . we cannot do it programatically . I also go through latin and softkeyboard . but i am still confuse.
MyInputMethod
public class MyInputMethod extends InputMethodService
{
private Keyboard mKeyboard;
private KeyboardView mInputView;
@Override
public void onInitializeInterface()
{
mKeyboard = new Keyboard(this, R.xml.qwerty);
}
@Override
public View onCreateInputView()
{
mInputView = (KeyboardView) getLayoutInflater().inflate(
R.layout.input_black, null);
mInputView.setKeyboard(mKeyboard);
return mInputView;
}
}
Simple Words:
I just want to show my keyboard on android device. I will add events later.
If you want want to make sure that your keyboard shows, you need to add other files as well. Like this.
Create method.xml file
Make a layout of your keyboard. layout/keyboard.xml
The keyPreviewLayout is the layout of the short-lived pop-up that shows up whenever a key on the keyboard is pressed.
layout/preview.xml
Next you need to make qwerty.xml for functionality. And you have already created the service class. But you have not implemented
OnKeyboardActionListener
. Make sure you do.