Friday, November 27, 2015

Android Dev Summit: Amazing!

Google ran its first Android Dev Summit this November, and I gotta say, it was amazing.

Session Videos

The AV team edited and posted the videos within 2 hours of the talk, so everyone can enjoy the content. My absolute favorite was "Android Studio for Experts". So many tips and tricks!

Check out the playlist for more.


I took many sketchnotes during the summit. Here are a few of them:

I will scan them and add the high-resolution version to this PDF when I get home: Download the current edition to get an email when it is updated.


Android Dev Summit gave us Android developer lots of in-depth technical content and easy access to the team. I hope Google will do it again!

Saturday, November 7, 2015

2016 Speaking Goals

I started public speaking in 2012 with a New Year's Resolution. It was a great way to gather my thoughts on what I want to share, and have grown a lot since then as a speaker. Last year Cate and I started Technically Speaking to help other people to start speaking at technical conferences, and we would like to take advantage of the new year to get more people to set speaking goals.

As a part of our birthday celebrations, Technically Speaking is offering 1-hour mentoring sessions to help people turn ideas into reality.

To get the ball rolling, here are my goals:

  1. Revamp my speaker page
  2. Give a keynote
  3. Help 3 first-time speakers give talks at conferences

Revamp my speaker page

Currently my speaker page is a list of all the talks I have given. I would like to update it to highlight certain talks, embed some videos, and also state my speaking requirements. I really like how Rachel Andrew explains her policy, and would like to create something similiar.

Give a keynote

I gave my very first keynote at Android Summit this year. I prepared a lot more than a tech talk, but it was also a lot more rewarding, because as a keynote speaker I try to motivate people to step out of their comfort zone. I would like to do that again.

Help 3 first-time speakers give talks at conferences

Navigating the speaking scene can be quite daunting, especially if you have never given a talk before. I broadcast tips and tricks on Technically Speaking, but nothing beats 1-on-1 mentoring, both for the mentor and mentee. As a mentor, I get the satisfaction of seeing concrete results.

Help me help you achieve your goals and mine. Post yours!

Friday, November 6, 2015

MVP: The Missing Link

I have been wanting to learn the Model View Presenter pattern for a while, and was super excited to get Michael Cameron to give a talk on it at GDG Boulder last night.

View Interface

I have this vague notion that MVP is good for JUnit testing, and I finally figured out why. The secret, the missing link, is View Interface, which is not a part of the MVP acronym. View Interface defines the contract between the view and the presenter, allowing you to mock one while testing the other.

With View Interface, you can compartmentalize your Android UI code into the view (typically a Fragment or Activity), which communicates with your presenter solely through the View Interface. This separation allows you to mock your View Interface with zero Android code, which means you can test your presenter with JUnit on the JVM.

Mocking via build flavors

Mocking is essential for hermetic testing, but people are often intimated by dependency injection frameworks like Dagger. If you prefer, you can provide mocks to your test using build flavors. An excellent technique!


Mockito is a great mocking framework with a fluent API. One very nice feature is mocking via annotations. To use that, annotate the fields you want to mock with @Mock, and initialize them all with MockitoAnnotations.initMocks() in your @Before function.

private MyThing myThing;

private OtherThing otherThing;

public void setUp() throws Exception {

This is equivalent to:

private MyThing myThing;
private OtherThing otherThing;

@Before public void setUp() throws Exception {
  myThing = Mockito.mock(MyThing.class);
  otherThing = Mockito.mock(OtherThing.class);



Google has published the excellent Android Testing Codelab going through an app with the MVP architecture. You can see JUnit and Espresso testing in action, mocks via build flavors, and various other techniques. Go check it out!

Thursday, November 5, 2015

Google Games: Leaderboard + Achievements

I have a weakness in cute things. I often play cute games, telling myself that I do it to "learn about game mechanics". This time, I actually integrated Google Play Games Services due to inspiration from playing!


My latest addiction is Alphabear. You earn bears while playing a word game, which gives you extra powers. They show you the list of bears you have collected:

I want that for Fit Cat! A catalog, if you will, showing all the cats that you have seen. Initially I was going to do the UI and tracking myself, but then I came across Google Games Achievements. Perfect!


When I started looking into Google Games, I learned about Leaderboards as well, which seems a simpler concept to launch with. I just need to submit the number of steps to Google Games, and everything else is handled for me. Great!

One problem though: Fit Cat is a watch face, and the watch does not have direct internet access. To upload the steps, I transfer the data to the phone using the Wearable Data Layer API and send it to Google Games in a WearableListenerService.

To test that, I needed to pace around the house, because the Data Layer API only syncs when the data changes. If I sit on my chair in front of my computer, the number of steps stays the same, and so I will not get a callback. It was pretty hilarious, me pacing around and rushing back to the computer to check the logs and see if the phone received data.

Placeholder achievements

I was going to publish my game with the leaderboard, but got blocked because Google Games requires at least 5 achievements. This was right before Big Android BBQ, and I did not have a lot of time before flying to Texas. So I added 5 placeholder achievements and made them hidden, and launched.

Actual Achievements

After I launched leaderboard, I wanted to go back to repurpose the hidden achievements to show cats. I want them to be public so that you are motivated to reach a goal level to see a certain cat.

Alas, I cannot switch an achievement from hidden to public once I published them. So I created new achievements for the cats.

While "May appear at 10000 steps" gives people a goal to walk more, "Secret" is just really mean if it is not attainable. I was holding off the launch until I came up with 5 achievements to backfill the placeholders. That took a few days, but I now have some fun ones for people to discover!

Play Games app

The nice thing about integrating with Google Play Games Services is that your game will show up in the Play Games app. Friends can compare achievements with each other, which is really fun.

However, Fit Cat was not showing up, and I was not sure why. Turns out you need to categorize your app as "Game" rather than "Application" on Google Play, so now Fit Cat is a "Sports Game".

Usually you play sports games by tapping your fingers on screen and pretending to be playing sports, but this one you actually play with your feet in real life!

Easy gaming

Google Play Games Services has a lot of built-in UI, making it super easy to add gaming to your app, even for a non-game like Fit Cat. There was a few non-obvious requirements (ahem, minimum 5 achievements), so I'd recommend going through the checklist during planning, not before launch like me.

Overall it's a great enhancement to my app, for very little effort. I hope you like it too!

Saturday, October 24, 2015

Big Android BBQ

Just got back from Big Android BBQ, and it has been super fun!

Korean mall

I arrived the day before the conference to hang out with Virginia Poltrack, my partner on Fit Cat. I needed a pencil case for my Copic markers so we went to the Korean mall in Carrollton.

First stop was H-Mart, where we ate some yummy dumplings and bought Asian fruits and snacks. And then we went to Daiso, my favorite Japanese dollar store.

I found the perfect pencil case! It was actually a water bottle case, but the top-opening zipper let me see the color of all my markers. I love it.

BBQ decor

The Big Android BBQ team did an amazing job on the decor. The keynote stage was a diner set, and there were lots of nice touches everywhere.

Tech talks

To be honest, when I first looked into this conference I was worried that it is more of a party than a technical conference. I decided to go any way, betting on Google Developers to provide a healthy dose of Android on top of the BBQ.

Colt McAnlis opened the conference with a hilarious Texan keynote.

I went to the automatic performance testing codelab, which was really good, albeit the facilitators running it way too fast.

I ended up not going to too many Google sessions because I brought 3 lady speakers from Colorado with me, and they all gave excellent talks!

I also really enjoyed the animation talk by Marie. Love her method of sticky note + stop motion video for prototyping!


I gave my Advanced Android Espresso talk towards the end of the last day. It was my second time giving this talk, so I was pretty relaxed about it. But the projector stopped working in the middle of my presentation! I stood on stage not sure what to do, and literally said, "Help!"

The AV technician came to debug, at which point all the plugging and unplugging crashed my laptop. So I asked to borrow a computer from the audience. After a while the projector was finally working, and what did I do? Accidentally close the browser on my loaner laptop, which had the slides preloaded. The conference wifi wasn't connecting, so a friend set up his Android phone as a wifi hotspot.

With all that, I finally resumed my presentation. I think I stayed quite calm during the whole fiasco, but it totally disrupted the flow of my talk. I was very pleased that the talk was recorded though, and the AV team at Google did an amazing job with the editing. I had to watch it 3 times to find the cut point!

Super friendly crowd

I really enjoyed Big Android BBQ. Everyone is so friendly, and there were many fun little details. The sessions vary in technical depth, but caught quite a few good ones. All in all a great event!

Tuesday, October 6, 2015

Espresso: Save and restore state

Do you save and restore state of your activities, fragments and custom views? Do you test them?

One way to test saving and restoring state is to rotate the screen in your Espresso test.

private void rotateScreen() {
  Context context = InstrumentationRegistry.getTargetContext();
  int orientation 
    = context.getResources().getConfiguration().orientation;

  Activity activity = activityRule.getActivity();
      (orientation == Configuration.ORIENTATION_PORTRAIT) ?

With this helper function, you can write tests like this:

public void incrementTwiceAndRotateScreen() {

      .perform(click(), click());



Source code under rotate-screen

Like this article? Take a look at the outline of my Espresso book and fill in this form to push me to write it! Also check out the published courses:

Saturday, October 3, 2015

How I prepared my keynote

The idea

My speaking buddy Corey Latislaw and I were both speaking at Write/Speak/Code. We talked about taking our speaking career further, and decided that keynote will be the logical next step. We were not sure how people get to keynote, but figured that we can brainstorm ideas and submit them as conference proposals.

Corey ended up keynoting at Droidcon NYC and I gave my keynote at Android Summit, just half a year since that day we brainstormed. Not bad!


This is a fancy word for cutting paper into little pieces, write one point on each, and arrange them on the table. This is how I organize my ideas. I like the transient feeling of pencil and paper. Nothing is set in stone, and I am free to rearrange everything.

Talk it out

Once I organized the storyboard into a linear narrative, I sounded out the ideas i.e. I gave a very early version of the talk to a lovely white wall in my house.

It was horrible. I stumbled in many places, unable to vocalize my thoughts. Normally I just talk to my technical slides without any scripts, but a keynote is very different. I need a strong narrative, and I decided that scripting is the way to go.

Write the script

I started writing my talk as if it was a blog post. Unlike speaking to my pencil-and-paper slides, I can jump from place to place to flesh out the paragraphs. I wrote 5 pages of text, and felt really good about it.

Read the script to time it

Next I read my script aloud to see how long it would be. It was 11 minutes, and I panicked, because my keynote was supposed to be 30 minutes.

Add more material

I knew I needed to add more material, but I was not sure what. At that point I was hosting the Technically Speaking hangout, and after we got off air I told Caroline Goyder that I am short on material. She told me to tell stories. Of course!

I added some personal stories, and also added a section at the end to give some counter points to balance the rosy picture I painted in the early part of the talk.

Make slides

My talk was much more meaty at this point, and it was time to try talk it out aloud to actual slides. That meant I had to make the slides.

My slides had a lot of illustrations. I redrew the pencil-and-paper slides on a drawing app on my tablet and imported them into Keynote, adding drop shadows to make them pop.

You can read more about how I draw the slides here: How to make hand-drawn slides.

Practice with my slides

Once the slides are done, I read my script while advancing the slides. It was 25 minutes long, which was perfect. Next I gave the talk to myself with just the slides, no script or speaker notes, to make sure there were enough visual cues for me to remember the flow. I recorded this version with Quicktime so I can make timing adjustments as necessary.

Live audience via Google Hangout

I want to get some feedbacks for my talk, so I scheduled a Google Hangout with my friends to give it to a live audience. We had quite some technical hiccups, namely, they could not see the slides. As a result some part of the talk was a bit confusing, but overall they liked the content, and gave me some pointers to improve.

Schedule tweets

Finally, I scheduled some tweets with Buffer so the audience can get relevant links as I speak.

I wrote a separate blog post to explain how I did it: Live tweet my own talk.

My outfit

I want to wear a dress for my keynote, but I need somewhere to clip the microphone. A belt wouldn't work since the dress I picked didn't have belt loops, and I didn't want to wear a jacket. I ended up wearing shorts under my dress.

The bad news is that I had to run to the bathroom to clip the microphones onto my shorts and thread them up to my neckline. The good news is that the shorts were robust enough to support the weight of two microphones, one for the sound system in the room, one for the video recording.

Show time

I went to the venue early to test the projector, walking to the back of the room to make sure that the text is readable. I also tried my presentation remote. After that I spoke with the cameraman and AV person to make sure that everything was in order. With that, I was ready for show time!