How to enable Hardware Acceleration on ICS, but disable in Gingerbread?

陌路散爱 提交于 2019-12-11 01:32:25

问题


I want my app to be hw accelerated in ICS, but support of 2.3.3 is still needed too. Can I enable HW acceleration for ICS only? Or I can only drop 2.3.3 support?


回答1:


Hardware acceleration was not added until 3.0. This is not an issue.

ref: http://developer.android.com/guide/topics/graphics/hardware-accel.html




回答2:


on ICS (android 4+) ,GPU acceleration is enabled by default and can be disabled in the manifest.

up to gingerbread, including, (up to android 2.3.x) , it's disabled since it's not available at all.

on honeycomb (android 3.x) , it's disabled by default , but can be enabled in the manifest.




回答3:


There is something else here.

I enabled hardware acceleration for one of my games and it worked fine for ICS, but when I uploaded into the market I got many reports saying that the game became barely playable.

I contacted one of those users and I provided him another version just with hw acceleration turned off. He claimed that it worked better, and he was using gingerbread.

According to the official documentation, enabling hardware acceleration does not have any impact on gingerbread. However my experience is that it has.

Also, the official documentation claims that if you don't declare it and your target is ICS, it is enabled by default. However, when I explicitly turned it on I saw a clear improvement on the animations, swiping and scrolling.

So, the official documentation is not correct and there is a reason to manually disable / enable hardware acceleration for some versions.

I will be disabling hw acceleration in the manifest and using the following code.

if (android.os.Build.VERSION.SDK_INT>=11) {
   getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}

I'll let you know if this solves my problems, I hope so.

Edit: It worked fine and I stopped having complains from the users.



来源:https://stackoverflow.com/questions/11109595/how-to-enable-hardware-acceleration-on-ics-but-disable-in-gingerbread

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