Publish Your Android App and Let Me Pay the Google Developer Fee
The best teachers are those that don’t make learning feel like a chore: learning happens as a byproduct of an interesting project or experiment. For app development, the best educational content is able to combine technical explanations with the joy of creating something new. That’s what I tried to do in my most recent series, which starts with a brand new Android project, and concludes with the My Memory app published to the Play Store. I think it does a good job doing both teaching 🎓 and building 🛠 and, if you’re interested in Android, I want you to try it.
In fact, if you follow the video tutorial series and customize the app in any way, I’d like to pay the $25 Google Developer fee so you can actually publish your app on the Play store :) Hopefully that provides a small bit of motivation to get you started. Having a published app is a valuable portfolio piece which can help in landing an internship or full time job. Here’s how this will work: once you’re done with the app, complete this short Google form with your contact/payment info. As long as it’s clear that you put in the effort, I’ll then send you $25 USD via Paypal or Venmo. I will sponsor the first 50 people who complete the project before February 1, 2021.
The app we build, My Memory, is a customizable, minimalistic, ad-free Android memory app. The game is inspired by the popular childhood image matching game, where you flip over 2 cards per turn trying to find matches. I’ve been playing a game of memory each morning as a fun way to start my brain :)
The main difference between this app and existing ones in the Play Store (aside from being ad-free) is the ability to create your own custom memory game using images from your phone. For example, each memory card could be a picture of your dog or your child around the house. Try out the game “corgi” as an example board, and let me know what games you create! Here are the main Android concepts we cover in the series:
Dynamic layouts and measurement
The size of each memory card in the grid changes based on how many cards are in that game of memory. Each memory card in a 6 x 4 grid will be smaller than a memory card in a 4 x 2 grid, since we have to fit more cards into the same space. Our app will dynamically adjust the size of the cards based on the width and height allocated to the container element, which is a RecyclerView. The RecyclerView is one of the most common components in any Android app. Typically it’s used for displaying a scrollable list of content, but in this case we’ll use it hold all the images of our memory game in a grid.
Navigation between multiple screens
Intents are fundamental to Android. You can think of them as requests to the Android system to perform a certain action, such as navigating to some part of your app, making a phone call, or invoking a system service. We also use the intent system in our app along with its capability to pass data along the request. In addition, we leverage two kinds of intents in My Memory: explicit and implicit intents allow us to navigate the user within and outside our application. Explicit intents are used when we launch the creation flow, since we want to explicitly specify the screen (or “activity”) that we want to navigate to. On the other hand, we use an implicit intent when we prompt the user to select photos for their custom memory game, since we don’t care which app the user chooses to complete that action.
Image loading (local + remote)
In the default memory game, we create some predefined icons for each card. These icons are actually vector icons, and Android Studio helps us create them from open source icons. The amazing thing about vector icons is that they are able to describe the image geometrically: they describe the points, lines, and curves of the image as a set of coordinates, along with an associated color. This leads to a much smaller image size compared to traditional ways of defining images (JPG or PNG format) where you need to define the color of each pixel in the image. In addition, these vector icons are infinitely scalable and can easily be drawn at any size since it’s just a question of doing some math on the coordinates.
In the case of playing a custom game, we use Picasso to handle the remote image download and display. We also explore some interesting optimizations around how to make the image loading feel snappier in order to deliver a better user experience.
Persistence with Firebase
Finally, a really interesting part of My Memory is the ability to create and save your custom memory game using the images on your phone. We leverage Firebase Storage to store the images, and then use Firestore to associate the game name to the list of image URLs of the game. The operation to upload an image to Storage is an example of an asynchronous operation, which means that we need to wait for the result of the operation through a callback. In general, anything with the internet must be asynchronous since I/O operations are slow and not guaranteed to succeed.
For example, what if your network connection is very slow? Or you walk into an elevator and the upload operation gets interrupted? The challenge with the Storage and Firestore interaction is to determine how and when the operation to save the memory game has succeeded.
- YouTube explainer video
- Github repo: https://github.com/rpandey1234/MyMemory
- Published app in the Play Store: https://play.google.com/store/apps/details?id=com.rkpandey.mymemory
Let me know if you have any questions! I’m really excited to see what you all build. Follow me on Twitter: https://twitter.com/rpandey1234