Use Color Filter • Faster way to experiment with color schemes. • Reduce the number of assets, which in turn reduc the apk size. • Less memory used as the number of assets are reduced.
Code ImageView redCircle = (ImageView) findV iewById(R.id.circle_red_imageview); ImageView greenCircle = (ImageView) findV iewById(R.id.circle_green_imageview); ImageView blueCircle = (ImageView) findV iewById(R.id.circle_blue_imageview); // we can create the color values in different ways: redCircle.getDrawable().setColorFilter(C olor.RED, PorterDuff.M ode.M U LTIPLY ); greenCircle.getDrawable().setColorFilter(0xff00ff00, PorterDuff.M ode.M U LTIPLY ); blueCircle.getDrawable().setColorFilter(getResources().getColor(R.color.blue),PorterDuff.M ode. M U LTIPLY );
Compatibility • You can use the native WebP decoder on 4.2 and later. • For lower versions, use libpng to convert to PNG format and then use it in the app.
Other Libraries • Use programs like OptiPNG, TruePNG and PNGC to significantly reduce the size of PNG images. • Use mozjpeg for jpeg images. • 5-10% size reduction • Won’t cause any visible changes to the images.
Remove Unused Content • Use Resource Shrinking. • Use tools like Lint and ProGuard. • Use Android-Unused-Resources jar file if you are still using Eclipse. https://code.google.com/p/android-unused-resources/
Appropriate Image Size • Store multiple image sizes on the server • Low-res devices might never need a full resolutio image • Most times the smallest image size is sufficient.
Checksum • Avoid transfers as much as possible. • For file transfers, first compute the md5 checksum and send it to the server to check if it already exis on the server. • The cost to upload the entire file again can be avoided.
Transfer in blocks • Do data transfers in blocks. • Keep track of the blocks that have been transferre and yet to be transferred. • The block size can vary based on the type of connection.
Testing for different networks • Facebook recently open-sourced Augmented Traf Control (ATC). • It is a tool to simulate network conditions. • It can simulate 2G, Edge, 3G, and LTE networks. • Has multiple profiles for a lot of different countri http://facebook.github.io/augmented-traffic-control/
Code int year = Y earC lass.get(getA pplicationContext()); if (year >= 2013) { // Do advanced animation } else if (year > 2010) { // Do simple animation } else { // Phone too slow, don't do any animations } https://github.com/facebook/device-year-class
Redesign • Remove features from low-end devices if they wo have the best user experience. • This could be animations, videos or even functionalities. • No feature >>> Bad feature