Is it possible to embed a web-view into an android keyboard replacement app?
I have an interface written in javascript, and would like to embed that into an android keyboard replacement app. It will need to be able to detect touch events, and send text strings back to the native UI from the web-view.
I have searched google for this, but can not find any onformation on how to create web-view in keyboard replacement app.
EDIT: Created github project for boilerplate based on the on the answer from @ckozl
https://github.com/billymoon/javascript-android-keyboard-boilerplate
Yes. In short. Not a great idea but technically feasible.
Let me walk you through a quick sample project, adapted from the SoftKeyboard sample included with the android SDK. Now there are a number of other technical issues to tackle but this should provide you with a basic starting point….
For starters, lets create a basic layout to use as our keyboard:
\res\layout\input.xml:
this is required by android to accept our IME
\res\xml\method.xml:
now onto our manifest
\AndroidManifest.xml
obviously the
uses-sdkanduser-permissionare up to the app and not required by this code (i’m not using any internet files here, but you could, i tested it and it worked…)now define a simple keyboard
\src…\SoftKeyboard.java:
here we basically create a webview then populate it from a asset file and bind a simple interface to it after enabling javascript
here’s the asset html:
*\assets\keyboard_test.html*
and that’s it, run it and you’ll get a keyboard with a single button and when you push it the javascript will send text into the input composer…
hope that helps -ck