版權聲明:本文爲xing_star原創文章,轉載請註明出處!html
本文同步自http://javaexception.com/archives/203java
前面有一篇文章,記錄了我在app升級到targetSdk 27中,出現的bug,文章位於 http://javaexception.com/archives/184 。android
問題很奇怪,只在google nexus上出現,通過對特定的關鍵詞搜索,在stackoverflow上找到了一篇有價值的文章 https://stackoverflow.com/questions/48072438/java-lang-illegalstateexception-only-fullscreen-opaque-activities-can-request-oapp
在個人app中,設置的全屏主題樣式以下:this
<style name="AppTheme.NoActionBar.Fullscreen" parent="AppTheme.NoActionBar"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackgroundCacheHint">@android:color/transparent</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowFullscreen">true</item> </style>
這個回答https://stackoverflow.com/a/52964692/5279354 下面有一個頗有價值的評論回覆。google
To anyone else who stumbles upon this 「fix」 I had to set <item name="android:windowIsTranslucent">false</item> and also had to set <item name="android:windowIsFloating">false</item> before it would work.
按照這個說法,須要調整下全屏的主題樣式,修改後的結果是url
<style name="AppTheme.NoActionBar.Fullscreen" parent="AppTheme.NoActionBar"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackgroundCacheHint">@android:color/transparent</item> <item name="android:windowFullscreen">true</item> <item name="android:windowIsTranslucent">false</item> <item name="android:windowIsFloating">false</item> </style>
到此終於完美的解決問題。修改樣式後,app的targetSdk是27以及以上,都不會再致使google nexus系列的設備crash。spa