0

I am implementing an InputMethodService. I found out that in some use cases it is extremely easy to turn the device unintentionally so that the screen orientation changes. Unfortunately, this means that the application's view is re-created and the input method screen disappears.

The answers proposed in the numerous questions like Android - disable landscape mode? work for activities, but not for input method services. I cannot control the activities, they are written by 3rd parties; in addition, it is only my input method that happens to be prone to unintentional orientation changes, it would be wrong to lock orientation for other input methods.

Probably I should lock orientation only when the device is almost horizontal.

Maybe I could temporarily get the accelerometer for exclusive use.

So: how do I temporarily disable orientation changes from an InputMethodService?

Community
  • 1
  • 1
18446744073709551615
  • 16,368
  • 4
  • 94
  • 127
  • I sincerely doubt that this is possible. Please write your `InputMethodService` to survive orientation changes, whether those changes are "unintentional" or intentional. – CommonsWare Apr 12 '13 at 12:02
  • How? How can it survive if the Activity is killed and re-created? – 18446744073709551615 Apr 12 '13 at 12:09
  • Probably by not trying to have any particular state that needs to be saved, so that the fact that a configuration change occurred is not an issue in the first place. – CommonsWare Apr 12 '13 at 12:37

0 Answers0