问题
I have checked every possible solutions in all stack overflow solutions and other web sites also but no luck.
My Requirement is :
Phone - only portrait mode
Tablet - portrait and landscape mode.
So tried using following:
For finding device if it is a Phone or a Tablet I used
if (getResources().getBoolean(R.bool.is_sw_600dp_size)) {
intent = new Intent(LauncherEmptyActivity.this, SplashActivityTablet.class);
} else {
intent = new Intent(LauncherEmptyActivity.this, SplashActivity.class);
}
And for my requirement if I set orientation as following for all activities (all orientation set at Manifest, tried also through programming but no luck)
LauncherEmptyActivity - Set Sensor
(or Set any of these above - "nosenser", "userSensor", "unspecified", "fullUser", "user")
SplashActivity - Set Portrait
SplashActivityTabet - Same As LauncherEmptyActivity
Result :
Application open in both portrait and landscape mode in Tablet (Expected O/P)
But for Phone If it is held in landscape mode then - SplashActivity will be landscape for brief moment and then it will be in portrait (This is the issue and I dont want that for brief moment).
Issue happens in
Device - Nexus 5x (Nought),
Emulator - Google Pixel (Oreo)
But working fine in Device - Moto G4 Plus (Nought)
This is for more explanation purpose, Following solution perfectly fine If my requirement is
(working fine for all above devices mentioned)
Phone - only portrait
Tablet - only landscape
LauncherEmptyActivity - Set Portrait
SplashActivity - Set Portrait
SplashActivityTablet - Set landscape
(all orientation set at Manifest)
Result : Correct As Expected
来源:https://stackoverflow.com/questions/46427110/some-devices-are-taking-different-orientation-for-brief-moment-then-what-i-set