How Easy Is Android 3.0 Hardware Acceleration?, Page 2
How Do I Turn Android 3.0 Hardware Acceleration On and Off?
You can turn hardware acceleration on by setting the android:hardwareAccelerated attribute to true in your Android manifest file. If you want your entire app accelerated, you set this attribute in the application tag. If you want only specific activities to be accelerated, simply turn off acceleration for specific activities by setting the same attribute android:hardwareAccelerated at the activity level to false.
For finer-grained control, you can also enable hardware acceleration at the window level by setting the
FLAG_HARDWARE_ACCELERATED parameter. See the Android SDK documentation for details, including sample code.
Finally, you can toggle hardware and software acceleration at the View level using the
setLayerType() method. See the Android SDK documentation for details on the
Is Android 3.0 Hardware Acceleration Really That Easy?
Well, yes and no. You still need to follow best practices for application design and in some cases, your application may need to be modified to really take advantage of the GPU. For example, keep your screens simple and limit the number of View controls, amongst others. Again, see Romain Guy's post for some do's and don'ts for writing GPU-friendly apps.
As you upgrade your applications to 3.0 and beyond, there's little reason not to turn on hardware acceleration for a smoother, more responsive experience for your users. Enabling your application to take advantage of the hardware acceleration available on devices running Android 3.0+ can be as easy as setting a flag in your application Manifest file and updating your application. You can also fine-tune your application graphics acceleration at the application, activity, or view level. As more users migrate to these newer versions of the Android SDK, this simply change to your app can help differentiate your from your competitors and please your users.
About the Authors
|Shane Conder and Lauren Darcey--Contributing Editors, Mobile Development--have coauthored two books on Android development: an in-depth programming book entitled Android Wireless Application Development (ISBN-13: 978-0-321-62709-4) and Sams Teach Yourself Android Application Development in 24 Hours (ISBN-13: 978-0-321-67335-0). When not writing, they spend their time developing mobile software at their company and providing consulting services.|