Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:22:44+00:00 2026-06-10T00:22:44+00:00

Under the Statusbar, there are five buttons – Wifi, Bluetooth, GPS, Silent Mode and

  • 0

Under the Statusbar, there are five buttons – Wifi, Bluetooth, GPS, Silent Mode and Auto Rotation. I haven’t figured out a way yet to detect when a user click the Auto Rotation button.

What I have done is have a Service that listen for orientation changes, like:

public class MyService extends Service {

    @Override
    public void onCreate() {
       super.onCreate();
       IntentFilter intentFilter = new IntentFilter();
       intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
       this.registerReceiver(myReceiver, intentFilter);     
    }

    public BroadcastReceiver myReceiver = new BroadcastReceiver() {
       @Override
       public void onReceive(Context context, Intent intent) {
          if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
             // Show a message about orientation changes.
             // This method is only called when the phone is physically rotated.
          }
       }
    }  
}

The above BroadcastReceiver will only work if the phone is physically rotated, but if the Auto Rotation button is clicked without any physical rotation of the phone, then the BroadcastReceiver method is never called.

I have also tried OrientationEventListener – but same behaviour as the BroadcastReceiver method.

To set orientation, I used the following method:

Settings.System.getInt(context.getContentResolver(), "accelerometer_rotation")

So I know there’s a method to interrogate System settings. Is there an Intent that traps system setting’s [orientation] changes? I’ve gone through Android docs but can’t find one – perhaps, I’m looking in the wrong place, or there’s no Intent for it.

Does anyone know a way to trap changes to the Auto Rotation button in the Statusbar?

UPDATE 1: The devices I’m working with are: Samsung Galaxy S3, Samsung Galaxy S2, Samsung Galaxy S and Samsung Galaxy Ace and many other. All of these devices are running stock ROM and have the Auto Rotation button under the Statusbar.

UPDATE 2: There have been suggestions advising to use the ContentObserver to listen for changes to system setting, for example:

public class SettingsContentObserver extends ContentObserver {
    public SettingsContentObserver(Handler handler) {
       super(handler);
    }

    @Override
    public boolean deliverSelfNotifications() {
       return super.deliverSelfNotifications(); 
    }

    @Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);
        Logging.writeDebug("Settings change detected: " + selfChange);
    }

    public void registerContentObserver(Context context) {
        context.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, this);
    }

    public void unregisterContentObserver(Context context) {
       context.getContentResolver().unregisterContentObserver(this);
    }
}

However, I found that the selfChange variable in onChange method always return false.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:22:45+00:00Added an answer on June 10, 2026 at 12:22 am

    I guess you will have to listen for Settings.System.ACCELEROMETER_ROTATION.
    Havent tried but this should work.

    getContentResolver().registerContentObserver(Settings.System.getUriFor
    (Settings.System.ACCELEROMETER_ROTATION),
    true,contentObserver);
    

    Edit:
    Just like Onrecieve of BroadcastReceiver there is a onchange of contentobserver. SO whenever the button is clicked you will get a callback here.

    private ContentObserver contentObserver = new ContentObserver(new Handler()) {
            @Override
            public void onChange(boolean selfChange) {
               // show a toast here
            }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Under the .NET Compact Framework, there is no FormWindowState.Minimize value. How can I minimize
Under windows , we frequently use event to synchronize threads. Under java, is there
Under Delphi XE, is there an ANSI version for Copy? I am using Copy
Under iOS there are several built in hooks for launching service-specific apps based on
Under VS's external tools settings there is a Use Output Window check box that
Under .net (specifically C# really), is there an equivalent to Java's DataSource class? I'm
Under Ubuntu 10, I installed using: npm install js2coffee Seems to install smoothly I
Under what specific situation is it ok (or even recommended) to present end-users with
Under Windows 7 I have a batch file for checking the status of some
Under MacOSX, I can create a file under root (/) without having admin rights.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.