3

In most of the apps Ive developed I just let android handled my configuration changes which worked fine but now in the latest app Im working on I have all my views set to landscape. When a user opens their keyboard on any hardware that has a hard keyboard the app simply closes itself with no force close. It just simply shuts down. I know you can use a save state and do all kinds of things listening for a keyboard open event but all I need to do at this point is just keep the app running when the keyboard is open without anything else special. The view is already set to landscape in the manifest so how can I just simply keep the app from closing when the keyboard opens.

James andresakis
  • 5,335
  • 9
  • 53
  • 88
  • 1
    what are you currently doing when/if you capture he open keyboard event? if you are, could you post that code? – L7ColWinters Feb 02 '12 at 02:05
  • currently Im not doing anything to capture the keyboard event. I saw in some forum that I cant find at the moment that if you just put @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } in your code it would keep your onConfigchanged empty but that hasnt worked for me. – James andresakis Feb 02 '12 at 02:09
  • 1
    if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { //handle keyboard slide out event } else if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) //handle keyboard slide in event } http://stackoverflow.com/questions/5046748/any-android-event-when-keyboard-slide-out – L7ColWinters Feb 02 '12 at 02:11
  • yeah but do I have to put everything thats in my onCreate or onResume inside {//handle change} ? thats what I dont know. – James andresakis Feb 02 '12 at 02:16
  • 1
    http://stackoverflow.com/questions/2785843/how-can-i-prevent-my-android-app-service-from-being-killed-from-a-task-manager – L7ColWinters Feb 02 '12 at 02:20
  • Hey thanks for the help bro :) I just went with what was posted below – James andresakis Feb 02 '12 at 02:48

1 Answers1

3

in the <activity> tag in your manifest, try adding:

android:configChanges="keyboardHidden"

That should make the activity call onConfigurationChanged in your activity (which you can ignore if you have nothing to change on the keyboard state change) and not restart on keyboard state changes.

You can read about runtime config changes here: http://developer.android.com/guide/topics/resources/runtime-changes.html

And about the activity tag properties here: http://developer.android.com/guide/topics/manifest/activity-element.html#config

Matt
  • 492
  • 2
  • 12