- Home /
 
Unity Android Service Not Running
I am trying to create a 3D keyboard in Unity for Android that can interface with Android webviews. From what I understand, this requires writing a plugin that overrides the Android Input Method Service. I have written the service and for testing purposes I made it very simple and it as follows:
 package com.easywebviewtexture;
 
 import android.app.Service;
 import android.content.Intent;
 import android.os.IBinder;
 import android.inputmethodservice.InputMethodService;
 import android.view.inputmethod.EditorInfo;
 import android.text.InputType;
 
 import android.util.Log;
 
 
 public class InputService extends InputMethodService  {
 
     private static InputService Instance;
 
     public boolean isInputActive = false;
 
     @Override public void onCreate() {
         super.onCreate();
         Instance = this;
     }
 
     @Override public void onStartInput(EditorInfo attribute, boolean restarting) {
         super.onStartInput(attribute, restarting);
         isInputActive = true;
     }
 
 
     @Override public void onFinishInput() {
         super.onFinishInput();
         isInputActive = false;
 
     }
 
     public static boolean GetKeyboardStatus() {
         return Instance.isInputActive;
     }
 }
 
 
               In order to enable the service, I add this code to the manifest file within Unity
          <service android:enabled="true" android:name="com.easywebviewtexture.InputService"
                 android:permission="android.permission.BIND_INPUT_METHOD">
             <intent-filter>
                 <action android:name="android.view.InputMethod" />
             </intent-filter>
         </service>
 
               However, when I am calling GetKeyboardStatus() in Unity with the AndroidJavaInterface, I get a null pointer exception, because Instance is not set, which suggests to me that the service is never even starting to begin with. Am I doing something obviously wrong?
               Comment
              
 
               
              Your answer