I have created a custom keyboard for my app. You can see the code for my keyboard below. I am getting error in xml viewer Similar question has been asked Android - Unsuppo
See this question and answers: Android - Unsupported Service: audio
In short: It is bug of android source. But I found solution how fix it.
Use KeyboardViewFix
as replace KeyboardView
:
public class KeyboardViewFix extends KeyboardView {
public static boolean inEditMode = true;
@TargetApi(21) // Build.VERSION_CODES.L
public KeyboardViewFix(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(inEditMode ? new ContextWrapperInner(context) : context, attrs, defStyleAttr, defStyleRes);
}
public KeyboardViewFix(Context context, AttributeSet attrs, int defStyleAttr) {
super(inEditMode ? new ContextWrapperInner(context) : context, attrs, defStyleAttr);
}
public KeyboardViewFix(Context context, AttributeSet attrs) {
super(inEditMode ? new ContextWrapperInner(context) : context, attrs);
}
public static class ContextWrapperInner extends ContextWrapper {
Context base;
public ContextWrapperInner(Context base) {
super(base);
this.base = base;
}
public Object getSystemService(String name) {
return Context.AUDIO_SERVICE.equals(name) ? null : base.getSystemService(name);
}
}
}
One note: On start your app, before any other code you need set KeyboardViewFix.inEditMode = false;
or you can get some errors.