android_study
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| android_study [2020/03/09 17:42] – jrseti | android_study [2020/03/10 01:58] (current) – [Background Location] jrseti | ||
|---|---|---|---|
| Line 17: | Line 17: | ||
| ====Background Location==== | ====Background Location==== | ||
| - | [[https:// | + | [[https:// |
| ====Saving Data==== | ====Saving Data==== | ||
| Line 401: | Line 401: | ||
| </ | </ | ||
| + | Smaller PNG data | ||
| + | |||
| + | * Use Web-P format. | ||
| + | * Web-P is supported natively | ||
| + | * Only helps with data transfer, still takes same size in memory | ||
| + | |||
| + | Scaling Bitmaps | ||
| + | |||
| + | * Resize images programmatically to the size they will be on screen. | ||
| + | * createScaledBitmap() | ||
| + | * Can scale image when loading with bitmapOptions | ||
| + | * Glide and Picasso libraries handle resizing | ||
| + | * | ||
| + | |||
| + | Reusing Bitmaps | ||
| + | |||
| + | * You can re-use bitmap objects | ||
| + | * Set the inBitmap option to a bitmap and the decode will reuse | ||
| + | * mBitmapOptions.inBitmap = mCurrentBitmap; | ||
| + | * Size must <= new bitmap size | ||
| + | * Avoids memory fragmentation | ||
| + | * Create ObjectPools, | ||
| + | * Use Glide library to do this | ||
| + | |||
| + | Perfomance Tuning Lifestyle | ||
| + | |||
| + | * Think about performance ahead of a time | ||
| + | * Gather, Insight, Action | ||
| + | * Use a tool to gather information. | ||
| + | |||
| + | Overdraw | ||
| + | |||
| + | * Overdraw is how many times a pixel is drawn in a single frame | ||
| + | * Turn on Show Overdraw in dev options to debug | ||
| + | * Tints showing overdraws | ||
| + | * Overlapping backgrounds | ||
| + | |||
| + | Understanding VSYNC | ||
| + | |||
| + | * Refresh Rate | ||
| + | * Frame Rate | ||
| + | * If refresh rate > Frame Rate, you get tearing | ||
| + | * Double buffering by the GPU | ||
| + | * VSYNC will copy from GPU to screen during VSYNC | ||
| + | |||
| + | Profile GPU Rendering Tool | ||
| + | |||
| + | * In dev mode on device | ||
| + | * Keep all bars < 16ms! | ||
| + | |||
| + | GPU | ||
| + | |||
| + | * DisplayList submitted to the GPU | ||
| + | * Turn on the GPU View in dev mode. Invalidates will show in red. | ||
| + | * Use Hierarchy Viewer | ||
| + | |||
| + | App Launch Time | ||
| + | |||
| + | * Don't display a splash screen | ||
| + | * Fix the main activity so the load time is quick | ||
| + | |||
| + | Smaller APKs | ||
| + | |||
| + | * Smaller resources | ||
| + | * In build.gradle in | ||
| + | * | ||
| + | < | ||
| + | BuildTypes{ | ||
| + | Release { | ||
| + | minifyEnabled: | ||
| + | shrinkResources: | ||
| + | proguardFiles getDefaultProguardFile(' | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * Toss out images you don't need for all resolutions. | ||
| + | * Use " | ||
| + | * Rotate images instead of separate images. | ||
| + | |||
| + | * Smaller code | ||
| + | * minifiedEnabled: | ||
| + | * Optimize code like enums (which get inflated to a class) | ||
| + | * JARs can be large. Proguard only helps a bit. Find smaller alternatives. | ||
| + | * You can split APKs into different versions | ||
| + | * | ||
| ====Tools to use==== | ====Tools to use==== | ||
| - | * Systrace | + | * Systrace |
| * Network Monitor Tool - in Android Studio | * Network Monitor Tool - in Android Studio | ||
| * Network Attenuator from AT&T | * Network Attenuator from AT&T | ||
| Line 410: | Line 496: | ||
| * TraceView | * TraceView | ||
| * Battery Historian | * Battery Historian | ||
| + | * DDMS in Android Studio. Best of all memory tools | ||
| + | * Heirarchy View | ||
| + | * On device tools: Profile GPU (Rendering), | ||
| + | * Heap Tool | ||
| + | * Memory Monitor | ||
| + | * Start Method Tracing Tool | ||
| + | * Method Profile Tool | ||
| + | * APK Analyzer | ||
| + | |||
| + | Vector Drawable | ||
| + | |||
| + | * One file generates all resolutions on demand | ||
| + | * Can be animated with an XML file | ||
| + | * Can take more time to load into GPU | ||
| + | * Pay attention to the complexity of the paths in your vector data | ||
| + | |||
| + | |||
| - | NOTES: | + | ====NOTES:==== |
| New Java 5 syntax: | New Java 5 syntax: | ||
android_study.1583775771.txt.gz · Last modified: 2020/03/09 17:42 by jrseti