Writing an Android app is easy, but making it "smooth" is not always simple. The UX demands and over 1000 different Android devices present a big challenge for any new and existing app. Learn some methods to optimize your app an make it up to the challenge
2. We'll talk about..
Graphics:
Over Draw
Detect UI glitches
Optimizing layouts with HierarchyViewer
Profiling with Traceview
Helping the GC with HPROF
Playing tough with StrictMode
Getting intimate with the OS using EventLog
Hardware Accelerate your app
Tips
4. Over Draw
Draw something on top of
something else 4x
Rule aim overdraw to 2x 3x
Could indicate a complex
2x
hierarchy
Show GPU overdraws on
Developer options (4.2+)
1x
5. Over Draw Solutions
Remove default background
getWindow().setBackgroundDrawable(null)
<item name="android:windowBackground">@null
</item>
Transparent regions in
9patches
Use tools
Tracer for OpenGL
Hierarchy Viewer
19. Tips - Bitmaps
InJustDecodeBounds Load only
properties
InBitmap reuse other allocation
InSampleSize good for preview
Resource folders
20. StrictMode
Problems Detector
Single thread or the entire VM
Show dialog, write to Log and more..
Usually used to detect slow operations on
UI thread
Came with Gingerbread (2.3)
21. Log
EventLog
Adb logcat -b events
Framework level logs
DB and system operations
22. Hardware Acceleration
android:hardwareAccelerated="true"
or
targetApi >= 14
Efficient drawing model
Compatibility issues
Custom views
Unsupported operations
24. Tips
Always Measure
Lint
Comes with the SDK
Scan the project's for optimizations
Great Eclipse/IntelliJ integration
ListView Easy on the getView()
Alpha Watch it...
Storage Read/Write
Direct access inside the class (!Get/Set)
SQLite indexes