Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable hardware acceleration in Android app, targeting Honeycomb AND prior versions

To enable hardware acceleration in an Android 3.0+ app I can do this:

<application android:hardwareAccelerated="true" ... />

But the app won't build with that attribute present if I target an OS version pre-11. Is there a way to enable hardware acceleration in an app that targets both Honeycomb and prior, or is hardware acceleration only available for those creating apps that only work on 3.0+?

I had a look for a method on Activity but I don't see one.

like image 718
Ollie C Avatar asked Mar 01 '11 18:03

Ollie C


People also ask

Should I turn on hardware acceleration on android?

If your application uses only standard views and Drawable s, turning it on globally should not cause any adverse drawing effects. However, because hardware acceleration is not supported for all of the 2D drawing operations, turning it on might affect some of your custom views or drawing calls.

What happens when you enable hardware acceleration?

Turning on hardware acceleration improves your battery life, performance, and responsiveness. Hardware acceleration offloads certain tasks from the CPU to the GPU or any other specialized hardware that can do it more efficiently, resulting in faster processing times and longer-lasting batteries.

What is the use of hardware acceleration in android?

Hardware acceleration is the process to use device hardware to speedup drawing operations of android application. In other word, android use hardware acceleration to speed up 2D rendering or fast up the image and video rendering. It is by default enabled if your Target API level is >=14.

How do I enable GPU acceleration on android?

Go back to Settings, scroll down and you should be able to see a new option called Developer options. Tap on it. Scroll down to the Hardware accelerated rendering and enable the toggle next to Force GPU rendering.


1 Answers

Try to set build target to the 3.0 version, but set minsdkversion to the oldest version you want to support. It should at least allow you to build, but will not enable HW-acceleration on the older versions.

From the documentation:

Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to applications, to improve performance for many common 2D graphics operations. When the hardware-accelerated renderer is enabled, most operations in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This results in smoother animations, smoother scrolling, and improved responsiveness overall, even for applications that do not explicitly make use the framework's OpenGL libraries.

Have not tested the 3.0 API yet myself, but the documentation seems to say this should be supported...

<manifest ... >
    <uses-sdk android:minSdkVersion="4" 
          android:targetSdkVersion="11" />
    <application ... >
    ...
    <application>
</manifest>

(cut from Optimizing Apps for Android 3.0

like image 136
Arve Avatar answered Oct 19 '22 06:10

Arve