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!

Comments

Popular posts from this blog

Available Resources for Android

Using React Native in an Android Custom Keyboard

Popup Keyboard for Special Characters in Android