Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn on hardware acceleration if available (such Android 3+) with Android APK 2.2

I developed a application for Android 3.0, and it's runs perfectly well, but the client insist on compatibility with 2.2 devices.

Disabling hardware acceleration, using Android Compatibility Package, a NIO-backport support (For tasks and executors) and some reimplementation of View methods I was able to port my app for Android 2.2 and works really good, but if I run this apk into a newer device the performance is extremely slowly, so I want to know how to turn on hardware acceleration if available but still uses my 2.2 APK.

like image 902
Marcos Vasconcelos Avatar asked Apr 26 '12 18:04

Marcos Vasconcelos


2 Answers

Add android:hardwareAccelerated="true" to your manifest, either for the <activity> or the <application>.

This attribute will be ignored on older versions of Android, but will be honored on Android 3.0+.

This will require you to have set your build target to API Level 11 or higher, but you probably already have that.

like image 143
CommonsWare Avatar answered Nov 09 '22 02:11

CommonsWare


If you need support devises with old OS (2.3.X and older) version, not add android:hardwareAccelerated="true" to your manifest, try add this code in your java:

try { if( Build.VERSION.SDK_INT >= 11) getWindow().setFlags( 16777216, 16777216); } catch( Exception e) {} // FLAG_HARDWARE_ACCELERATED == 16777216 (0x01000000)

This is work in OS 3.0++ and not call error on 2.3.X and older.

like image 36
Tapa Save Avatar answered Nov 09 '22 01:11

Tapa Save