Posts

Showing posts from January, 2019

Android Toasts work!

If you've been using Custom Keyboards in Android, you've probably realised that it's quite restrictive. However, good news: you can use Toasts! I found this on Stack Overflow . Here's how: private Handler mHandler;   @Override public void onCreateInputView() {     // all your other code first...     mHandler = new Handler(); } @Override public void onKey(int primaryCode, int[] keyCodes) {     // And then...     mHandler.post(new Runnable() {                   @Override         public void run() {             Toast.makeText(MyIntentService.this, "Hello Toast!", Toast.LENGTH_LONG).show();                       }     }); } That's it!

Getting Started - Android

Getting Started Choosing a tutorial It seemed like the tutorials out there are pretty limited. I started with the one from Android Authority , but it's missing quite a lot. Luckily someone has linked a complete video in the comments , but you don't want to watch a half hour video, do you? Best to just jump to their source code . Below I try to detail all the missing steps. Let me know if I've forgotten anything. Creating Project When you create the project, select "Add no Activity". Missing imports If you're new to Android, it often helps to have the imports. import android.inputmethodservice.InputMethodService; import android.inputmethodservice.Keyboard; import android.inputmethodservice.KeyboardView; import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.view.inputmethod.InputConnection; Add the missing Android.Manifest <manifest xmlns:android="http://schemas.android.com/apk/res/android&