Some devices are taking different orientation (for brief moment) then what I set in Manifest

吃可爱长大的小学妹 提交于 2019-12-10 11:02:34

问题


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)

  1. LauncherEmptyActivity - Set Sensor

                        (or Set any of these above -  "nosenser", "userSensor", "unspecified", "fullUser", "user")
    
  2. SplashActivity - Set Portrait

  3. 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

  1. LauncherEmptyActivity - Set Portrait

  2. SplashActivity - Set Portrait

  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!