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

10 things Every Android Developer Should Know

Faisal Abid
October 26, 2012

10 things Every Android Developer Should Know

10 Things every android developer should know. My talk from AndroidTo

Faisal Abid

October 26, 2012
Tweet

More Decks by Faisal Abid

Other Decks in Technology

Transcript

  1. WHO AM I? • A software engineer and entrepreneur •

    On the tablet team at Kobo • Find me blogging at FaisalAbid.com • Tweeting @FaisalAbid
  2. AppStackNavigation • Up and Back are two different things now.

    As if things weren’t bad enough. • Up means going up to the next page in the app. • Back means going back irrespective of where you are. • You can control this stuff in code but it gets messy. • Android Jellybean introduces the new ParentActivity tag in the manifest
  3. Android Animations • More developers need to start taking advantage

    of Android. • Previous versions of Android did not do animations well • I hated the anim.xml files for simple animations • With Honeycomb, Android introduced .animate() on all views.
  4. ObjectAnimator & ValueAnimator • .animate() is powerful, but ObjectAnimator and

    • ValueAnimator are even more powerful. • ObjectAnimator allows you to animate any property of an object
  5. Quick Walkthrough - Parallax • Parallax’s are cool. Everyone wants

    to do it. • Lets do a quick walkthrough on how to build one using ObjectAnimator
  6. Summary - Parallax • Foreground has to be faster •

    ObjectAnimator animates it forward and backwards • I hated the anim.xml files for simple animations • With Honeycomb, Android introduced .animate() on all views.
  7. ValueAnimator • Not all views have all the properties ready

    to be animated using .animate() • ValueAnimator will handle the rest for you. • Animates the values from x to y. • Lets see how it works.
  8. ValueAnimator • That’s cool, but how do I animate it?

    • ValueAnimator will handle the rest for you. • Animates the values from x to y. • Lets see how it works.
  9. ProgressAnimations • It’s ugly. I hate it. You should hate

    it too. • Your app will almost always have a page where there is a wait time. Make it matter. • WhereIsMyBus has a cool progress animation • Let’s take a look.
  10. ProgressAnimations • Not using AnimationDrawable. • Causes OOM. AnimationDrawable likes

    to load everything. • Solution is by "Yar" from StackOverFlow http://bit.ly/ OsGSsb
  11. Handling OOM • Out of Memory errors are most common

    on Android. • Problem is phone dependent, which is the worse. • One of the reasons why iPhone apps look so pretty. They don’t have to worry about OOM as much.
  12. 1. Download image as a stream and save it to

    a file 2. Decode bitmap using decodeInBounds=true and get only width and height 3. Calculate scale using original height & width and your desired height & width 4. Decode saved bitmap using opts.inSampleSize set to your scale. 5. Optionally perform any matrix transformations to get accurate size. OOM Algorithm
  13. AsyncTask changes • AsyncTasks are awesome. • In previous versions

    of Android you could fire of a few AsyncTasks and let them do your bidding. • In ICS+, AsyncTasks now run serial by default. • This will cause headaches for you.
  14. ContentProvider with custom methods! • ContentProviders are really useful if

    you want to expose your apps data to other apps. • However very limiting. Only CRUD operations supported. • Honeycomb introduced .call() • This lets you create your own custom “API” for ContentProviders. • Possibilities are endless
  15. Android Crutons • Something cool I’ve been using in a

    lot of personal projects. • Toasts are very non-contextual. Very bad UX. Crutons on the other hand are very contextual. • Basically the small header/banner that stackoverflow shows when you login or get an award. • Images taken from http://android.cyrilmottier.com/? p=773
  16. oo oo aaa aaa, Monkey • Monkey is the single

    most useful tool on the Android SDK • Let monkey beat your app up and find what goes wrong and when. • adb shell monkey -p com.package.name -v x
  17. PSA: Boot Broadcast Listener Changes • Only applicable to a

    small # of developers, but one day it could be you! • Android has changed how the boot broadcast listener works. Your app can only listen to this if and only if the user has interacted with your app at least once.