Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
New Contributor
Posts: 9
Registered: ‎07-31-2013
My Device: developer
My Carrier: none
Accepted Solution

hide virtual keyboard crashes in Z10

Hi, I'm porting android app to Z10.

I'm using following code to hide the virtual keyboard in onCreate():

=================================================

InputMethodManager imm=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  imm.hideSoftInputFromWindow(mainActivity.this.getCurrentFocus().getWindowToken(), inputMethodManager.HIDE_NOT_ALWAYS); 

=============================================

 

However, it always crashes in BB10.2. 

Anyone can tell me how to hide the virtual keyboard?

 

Thanks

Retired
Posts: 264
Registered: ‎01-08-2013
My Device: BlackBerry 10 Dev Alpha B
My Carrier: Bell

Re: hide virtual keyboard crashes in Z10

Hey sgao,

 

How does it crash? Is there an exception trace?

 

    Justin

Justin Jasmann | Android Application Development Consultant
Developer Relations
developer.blackberry.com
New Contributor
Posts: 9
Registered: ‎07-31-2013
My Device: developer
My Carrier: none

Re: hide virtual keyboard crashes in Z10

I finally find the problem:
1. when I input something to Edit, click the "Next" button in virtual keyboard, it will focus on the button.
2. when I click the button, the "mainActivity.this.getCurrentFocus() " is return NULL. This caused the problem

Thanks anyway.