java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

前端 未结 30 1719
难免孤独
难免孤独 2020-12-02 04:43

I am facing the problem while retrieving the contacts from the contact book in Android 8.0 Oreo java.lang.IllegalStateException: Only fullscreen opaque activities can reques

30条回答
  •  半阙折子戏
    2020-12-02 05:23

    it seems when target sdk is pie (api level 28.0) and windowIsTranslucent is true

    true

    and you try to access orientation. problem comes with android oreo 8.0 (api level 26) there are two ways to solve this

    1. remove the orientation
    2. or set windowIsTranslucent to false

    if you are setting orientation in manifest like this

    android:screenOrientation="portrait"
    

    or in activity class like this

     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    

    remove form both places.

    and observed when u set windowIsTranslucent to true, it takes orientation from parent activity.

提交回复
热议问题