1

Is it possible in Android to capture screen rotate events but not actually have the activity respond to the rotate events?

To make things more difficult, I've got an activity backed by a TabActivity, and in one of the tabs I want to rotate some of the content area on screen - but leave the tab in portrait mode.

I've tried setting the activity orientation to portrait in the manifest, but then I no longer get the onConfigurationChanged(..) events. However, If I remove this line, the whole tab rotates as well.

Any help appreciated!

Codz
  • 315
  • 1
  • 2
  • 10

2 Answers2

1

You might want to add "orientation" to activity's configChanges property in AndroidManifest.

android:configChanges="orientation"

http://androidappdocs.appspot.com/guide/topics/manifest/activity-element.html#config

DenMark
  • 1,618
  • 1
  • 15
  • 16
0

Set the orientation to portrait mode in the manifest as you did, but listen directly to the accelerometer sensor (which is the sensor from which Android derives the orientation of the device) updates and parse them yourself to know when the orientation changed.

It's actually quite easy to do. See here for an example: http://www.anddev.org/accessing_the_accelerometer-t499.html

gby
  • 14,900
  • 40
  • 57
  • I basically did a variation of what you suggest - just listened to the events and fire my own local events when the orientation has changed. Thanks for your help. – Codz Apr 13 '11 at 22:44