Issue
I have been noticing a crash on Android 6 with error message - "A/OpenGLRenderer: Error: Ambient Vertex Buffer overflow!!!" Setting hardware accelerated to false for an activity in manifest file solves the problem, but affects the performance of the app (results into slower app).
I want to just set the value to false only if android version is 23 (android M) and not otherwise. Here is how I approached it:
Android Manifest file:
<activity
android:name=".MainActivity"
android:hardwareAccelerated="@bool/hardwareAcceleratedValue">
res/values/bool.xml
<resources>
<bool name="hardwareAcceleratedValue">true</bool>
</resources>
res/values-v23/bool.xml
<resources>
<bool name="hardwareAcceleratedValue">false</bool>
</resources>
With this, I was noticing slower performance on Android M devices (which was expected), but also on devices with Android 9. So I went ahead and created another folder for android 9 and added the file to it with "hardwareAcceleratedValue" as true and the performance was faster.
Question -
For android API's other than v23, shouldn't android read the "hardwareAcceleratedValue" value from res/values/bool.xml? Or will I have to create separate folders for every android API and create a bool.xml file within it i.e. res/values-v28/bool.xml or res/values-v27/bool.xml?
How can I just set "hardwareAcceleratedValue" to false only for Android-M or less and true for all versions beyond android-M?
Solution
For android API's other than v23, shouldn't android read the "hardwareAcceleratedValue" value from res/values/bool.xml?
-v23
is used for API Level 23 and higher.
How can I just set "hardwareAcceleratedValue" to false only for Android-M or less and true for all versions beyond android-M?
Have false
in res/values/bool.xml
and true
in res/values-v22/bool.xml
. Android M is API Level 21, so -v22
will be used for all higher versions.
If by "android-M" you mean Android 5.x, then have false
in res/values/bool.xml
and true
in res/values-v23/bool.xml
, as Android 5.1 was API Level 22.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.