How To Define The Screen Orientation Before The Activity Is Created?
I defined my activity to only be in portrait mode by : android:screenOrientation='portrait' When I take a picture with the camera function via intent, take this picture in landsc
Solution 1:
You can also register your activity to explicitly handle any orientation changes by adding android:configChanges="orientation"
to the activity definition and then overriding the onCofigurationChanged method in your activity like this:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
I'm not sure if it would help with your specific problem, but I remember doing this when I wanted an activity to only display in portrait mode. Let me know if it helps :)
Solution 2:
Add android:configChanges="orientation"
to your <activity>
tag. This way the activity will not be recreated on orientation change, but will just receive a callback onConfigurationChanged
which you can ignore.
Post a Comment for "How To Define The Screen Orientation Before The Activity Is Created?"