How do I get the CURRENT orientation (ActivityInfo.SCREEN_ORIENTATION_*) of an Android device?

后端 未结 8 1998
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 03:05

I would like to find out the detailed orientation of a device, preferably one of SCREEN_ORIENTATION_LANDSCAPE, SCREEN_ORIENTATION_PORTRAIT, S

8条回答
  •  死守一世寂寞
    2020-11-27 03:20

    getResources().getConfiguration().orientation is the standard way of knowing current orientation being used. However, if it doesn't fulfill your needs then perhaps you may use Sensors to calculate it in terms of angle. Read this and this

提交回复
热议问题