Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Droidcon Montreal 2015: Optimizing Your Apps Fo...

Droidcon Montreal 2015: Optimizing Your Apps For Emerging Markets

Talk that I gave at Droidcon Montreal 2015 about ways in which you can optimize your apps for markets which are driving the growth of smartphones.

vinaygaba

May 15, 2015
Tweet

More Decks by vinaygaba

Other Decks in Technology

Transcript

  1. 44 36 21 51 37 11 80 10 9 25

    66 9 Smartphone Feature phone Multimedia phone Brazil Russia India China
  2. 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.
  3. 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 );
  4. 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.
  5. 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.
  6. Code android { ... buildTypes { release { minifyEnabled true

    shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
  7. 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/
  8. 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.
  9. Code public static String getM D5EncryptedString(String encTarget){ M essageDigest mdEnc

    = null; mdEnc = M essageDigest.getInstance("M D5"); // Encryption algorithm mdEnc.update(encTarget.getBytes(), 0, encTarget.length()); String md5 = new BigInteger(1, mdEnc.digest()).toString(16); while ( md5.length() < 32 ) { md5 = "0"+md5; } return md5; }
  10. 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.
  11. 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.
  12. 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/
  13. 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
  14. 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