How do I determine whether or not the accelerometer would report a roll of zero when the bottom long side of the screen is facing the ground?
I need to do this without instructing the user t开发者_StackOverflowo hold the phone in a certain position. I am hoping to be able to do something like:
Context.getResources().getConfiguration().getNaturalOrientation == Orientation.LANDSCAPE
IMPORTANT: The above line of code is not possible, it's just an example of what I would like to do.
I found the answer for this. It's very simple using API8 and higher, simply use Display.getRotation()
this may help you to detect the configuration change
 @Override
        public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
            //onConfigurationChanged
            if (newConfig.equals(Configuration.ORIENTATION_LANDSCAPE)) {
                 //ORIENTATION_LANDSCAPE
            } else if (newConfig.equals(Configuration.ORIENTATION_PORTRAIT)) {
                 //ORIENTATION_PORTRAIT
                }
        }
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
 加载中,请稍侯......
      
精彩评论