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

Building for the next billion users

Building for the next billion users

Learn how to write a good android app

Sidiq Permana

April 02, 2016
Tweet

More Decks by Sidiq Permana

Other Decks in Programming

Transcript

  1. Building for theNext Billion Users Sidiq Permana Google Developer Expert

    and Intel Android Software Innovator TechMagician at Nusantara Beta Studio ID-Android Developer Tech Talk #4 Malang, April 2 2016
  2. 1.4 Bilion+ Active Android Users 400 OEMs and 500 Carriers

    Able to sell your app in 130 Countries Disribute to 190+ Countries 65 Countries that you can tailor your app pricing
  3. Data source: GSMA https://gsmaintelligence.com/metrics/1/0/data/?report=535ac4dab8137 Internet penetration per country: ITU Measuring

    the Information Society http://www.itu.int/en/ITU-D/Statistics/Pages/publications/anapub.aspx 1 billion new users are expected to come online by 2017, mostly from emerging market
  4. D World Bank country GDP classification: http://data.worldbank.org/about/country-and-lending-groups Human development index:

    http://hdr.undp.org/en/countries Socio-economic statistics: www.gapminder.org OECD countries: www.oecd.org 78% of the world’s population lives in emerging markets (5.7 billion people)
  5. It’s a Different Ballgame • Slow and Expensive Internet •

    Prepaid is used by >95% of users • Mobile first
  6. In short, we have to rethink about the parameters we

    consider when we are building mobile apps
  7. Top 11 Best Practices: Building for the next Billion Users*

    * Also the last billion, and the billion after the next
  8. Reducing Perceived Latency • Every UI action should have an

    immediate visible reaction ◦ Hide/show views, scrolling views, state changes • Every touchable item should have touch feedback ◦ Use touch ripple from android 5.0+ Material: Responsive Design goo.gl/zMDilf
  9. • Material design guidelines an extensive multi-year effort • Make

    user intuitively know how to use your app • Adaptive design methodology Material DesignSpec google.com/design/spec
  10. Prefetch Content Anticipate what content your users may want and

    have it ready Take advantage of good device state, be conservative instead
  11. Prefetch Content Use JobScheduler forAndroid 5.0+ There are alternatives forAndroid

    < 5.0: • Android Job by Evernote • GCM Network Manager Using Job Scheduler goo.gl/nK8X8g
  12. Be smart about mobile data usage Mobile Data mostly hast

    monthly quota and cost realmoney Smartphones aren’t as smart without mobile data
  13. Be smart about mobile data usage Mobile Data mostly hast

    monthly quota and cost realmoney Smartphones aren’t as smart without mobile data Managing Network Usage goo.gl/AZA23R
  14. What is WebP? • Open Source • Support lossy and

    lossless format • Supported Natively on Android since 4.0 and with Lossless Format since 4.2; Supported in Chrome and Opera • 24-34% better compression than JPEG; 28% better than PNG with little to no loss in visible quality
  15. Why WebP? • Reduce network usage • Reduce bundled image

    asset sizes in your app/game for faster installs and updates • Downside is encoding and hosting multiple formats WebP for developers goo.gl/laQtI4
  16. Put your APK on diet APK size matters Google Play

    smart app updates can help Avoid users turning off auto-updates
  17. Put your APK on diet • Choose drawable assets carefully

    ◦ Remember assets scaled down look OKbut not the reverse • Launcher icons include up to xxxhdpi ◦ Store in mipmap- directories (eg. mipmap-hdpi) • Remove unused code and resources ◦ minifyEnabled=true ◦ shrinkResources=true • Multiple APK an option but has tradeoffs
  18. Keep graphicsperformance smooth Aim for 60fps, this allows for ~16ms

    per frame (1000/60) Reduce “actual latency” - easier said than done
  19. Keep graphicsperformance smooth • Minimize layout overdraw and layout depth

    • Only run UI updates and logic on the UI thread • Memory allocations can cause GC ◦ Images often to blame - use a library like Glide or Picasso • Use on-device tools: GPU profiling and overdraw Performance patterns video series goo.gl/3dBbse
  20. Reduce Battery Usage • Avoid holdingWakeLocks directly ◦ Use FLAG_KEEP_SCREEN_ON

    andWakefulBroadcastReceiver • Use the new JobScheduler API in Android 5.0+ • Batch network transfers and connections • User facing battery blaming and new developer tooling Keeping the device awake goo.gl/EQVB0i
  21. Reduce Memory Usage Avoid long running services - be a

    good citizen More background memory usage leads to slower multitasking and less system efficiency
  22. Reduce Memory Usage • Subclass IntentService not Service • Let

    the system wake you ◦ GCM,JobScheduler,AlarmManager or other system events • ActivityManager.isLowRamDevice() ◦ ~512MB with 800x480 or less screen • Process stats and new memory monitor
  23. App Architecture The right app architecture can dramatically improve the

    user experience Optimize for fast, responsive UI that is not tied to long running operations like networkrequests Google I/O 2014 App github.com/google/iosched
  24. App Architecture • Ensure identical network requests are never duplicated

    ◦ Use a local database for long lived data ◦ Use a bounded disk cache for transitory data • Screens should still be navigable even if network is down • Never block the UI due to a long running operation ◦ Use inline loading spinners if needed ◦ Use AsyncTask but only for UI related background operations
  25. Three common problems • It can be difficult to integrate

    new features as you are worried about compatibility with the existing system. • Time is spent fixing old code, which have developed mysterious bugs that are hard to reproduce and to fix. • You may have forgotten what a lot of the code does, and so you may be afraid that touching it will break the system.
  26. Good code is understandable code Understandable code is easier to

    maintain, easier for new developers to learn, easier to debug, faster to find what you're looking for, and most importantly: helps that the programmers writing the code actually understand business objectives.
  27. Summary 11. Responsiveness 10. Material Design 9.Anticipate 8. Smart Datausage

    7. WebP 6. Put your APK ondiet 5. Smooth likebutter 4. Battery 3. Memory 2. AppArchitecture 1. Good Codes