I made an app using accelerometer but problem is whenever it detects rotation of the screen, it goes to main menu.
I used following code to disable rotation but it still detects the rotation action and goes to mainmenu although it does not become landscape mode anymore.
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
How can I prevent this rotation detection?
Put
android:screenOrientation="portrait"inside your activity tag in the AndroidManifest.xml file. That attribute defines that this specific activity should always be run in the portrait mode and thus Android will not try to change screen orientation on rotation.