Show soft input programmatically in android


I’m trying to set focus and displaying the keyboard programmatically but the code below only works for iOS:

const textField = <TextField>this.addTextField.nativeElement;

What Im trying in Android is the code below based on this thread but I have an Angular 2 project instead

showSoftInput() {
    const textField = <TextField>this.addTextField.nativeElement;
    const imm =;

But I get an exception. Anyone know how to achieve this?


What’s the exception?

I’ve written how to hide the keyboard which might help in the code where you need to get the input manager.

Just scanning your code it doesn’t look right. On my phone or I’d show you another way. When you provide the exception it’ll be easy to figure out what’s happening though.


I’ll paste the stack trace when Im back to my other computer. Regarding the link, where do you get the reference to “android” in the line below?

let inputManager = Context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE);


Just accessing the native android namespace. If you want intellisense and
use typescript the NS team has a typings for some help there. think it’s
tns-platform-declarations on npm.


The code snippet from my first post actually works, I just forgot to reference the android property of TextField.

showSoftInput() {
    const textField = <TextField>this.addTextField.nativeElement;
    const imm =;

The only thing missing now is that my TextField doesn’t get focus, so when I start typing nothing happens.