I am building an app that requires a lot of drawing on the canvas. I notice that the app is a bit laggy in devices with high resolution (nexus 7 for example). I saw there is a Force GPU option in the developer option. When Force GPU is enabled, my app runs absolutely smooth.
I have read that this Force GPU option is called Hardware Acceleration and it is available only for Android 3.0 and above.
My app is targeting Android 2.3 and above.
Is it possible to programmatically enable Hardware Accelerated (or Force GPU--whatever the magic is called) on any Android 3.0 or above devices?
Something like:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
Turn On Hardware Accelerate HERE but How can i do this?
any code snippet would be welcome/helpful/thanks
}
I assume you've already added android:hardwareAccelerated to your Manifest file?
<application android:hardwareAccelerated="true" ...>
That is what enables hardware acceleration within your application per the guide on hardware acceleration and should do exactly what forcing GPU does at a system level.