0

Basically I have Activity, which contains this line in the manifest:

android:screenOrientation="sensorPortrait"

So I can't rotate it and it's always in a portrait mode.

The issue is that I need to detect whenever user is trying to rotate the screen. I've already watched questions like : Remove orientation restricitons programmatically , How to detect orientation change in layout in Android? and so on.

By now I know that to do it you need t override this method:

@Override
public void onConfigurationChanged(Configuration newConfig)

And, in my case to use

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

To allow screen rotation. The issue in this approach is that I have a lot of fragments and will need to make sure that it wont affect others, which I don't want to do.

Question : Is there some way to have a listener when user is trying to make a screen rotation, but when you don't allow him to do so, in that way fragment wont change it's orientation, but I'll catch screen rotation action.

Please help!

Community
  • 1
  • 1
Nik Myers
  • 1,843
  • 19
  • 28

0 Answers0