Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:44:04+00:00 2026-05-30T12:44:04+00:00

Is it possible to embed a web-view into an android keyboard replacement app? I

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:44:05+00:00Added an answer on May 30, 2026 at 12:44 pm

    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:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    
        <WebView
          android:id="@+id/myWebView"
          android:layout_width="match_parent"
          android:layout_height="600dp"
        />
    
    </FrameLayout>
    

    this is required by android to accept our IME

    \res\xml\method.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <input-method xmlns:android="http://schemas.android.com/apk/res/android"  />
    

    now onto our manifest
    \AndroidManifest.xml

    <manifest 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        package="com.example.android.softkeyboard">
    
        <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="13" />
        <uses-permission android:name="android.permission.INTERNET" />
    
        <application android:label="SoftKeyboard">
    
            <service 
                android:name="SoftKeyboard"
                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>
        </application>
    </manifest>
    

    obviously the uses-sdk and user-permission are 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:

    package com.example.android.softkeyboard;
    
    import android.inputmethodservice.InputMethodService;
    import android.inputmethodservice.KeyboardView;
    import android.view.View;
    import android.webkit.WebView;
    
    public class SoftKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
    
        private WebView myWebView = null;
    
        @Override 
        public View onCreateInputView() {
    
            View view = getLayoutInflater().inflate(R.layout.input, null);
            myWebView = (WebView) view.findViewById(R.id.myWebView);
            myWebView.getSettings().setJavaScriptEnabled(true);
            myWebView.addJavascriptInterface(jsInterface, "android");
    
            return view;
        }
    
        private Object jsInterface = new Object() {
    
            @SuppressWarnings("unused")
            public void sendKeys() {
                getCurrentInputConnection().setComposingText("how do ya like me now?", 1);
            }
    
        };
    
        @Override
        public void onWindowShown() {
    
            super.onWindowShown();      
            myWebView.loadUrl("file:///android_asset/keyboard_test.html");
        }
    
        @Override
        public void onKey(int primaryCode, int[] keyCodes) {}
    
        @Override
        public void onPress(int primaryCode) {}
    
        @Override
        public void onRelease(int primaryCode) {}
    
        @Override
        public void onText(CharSequence text) {}
    
        @Override
        public void swipeDown() {}
    
        @Override
        public void swipeLeft() {}
    
        @Override
        public void swipeRight() {}
    
        @Override
        public void swipeUp() {}
    
    }
    

    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*

    <!DOCTYPE html>
    <html>
    <head>
    <title>test</title>
    <style>
    button {
    
        display:block;
        margin:300px auto;
        width:400px;
        padding:60px;
    
    }
    </style>
    </head>
    <body>
    
    <button onclick="android.sendKeys()">yeah buddy!</button>
    
    </body>
    </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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to embed an inline search box into a web page which
I'm developing a web app based on videos that my client would like to
I have developed a usercontrol that I would like to embed in Umbraco. The
I have a web app in http://domain1/app1/called.html , and I want to embed that
Is it possible to embed an application (like Preview, Pages etc) into a Cocoa
is there any way to integrate/embed JasperServer into another web app? The thing is
I have a program written in python, and I would like to make it
Is it possible to host/embed/ reparent a normal Windows Application into a web page
Possible Duplicate: How to embed a web browser control in a cross-platform application? I'd
Is it possible to embed an audio object (mp3, wma, whatever) in a web-enabled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.