[ANDROID] Prevent Activity from Auto-Rotating


Today topic is about how to prevent the activity ( not the whole system ) from rotating.

it’s quite simple, using the following lines of code:

private void adjustRotating(boolean isOff) {
if (isOff) {
} else {

Want to turn of rotating, call adjustRotating(true) and to turn it on back to normal, call adjustRotating(false)

No other settings in Manifest or anywhere else.

This is some sample code, you can take it from Mediafire http://www.mediafire.com/?pnx9tqmje8pkf6q

References :

Just one small problem when you try this snippset of code is that when you disable rotating detection
in your activity, if you’re in landscape mode, this code would turn your phone to default mode ( portrait mode).
So be careful when using this !


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: