O'Reilly logo

App Inventor by Ellen Spertus, Liz Looney, Hal Abelson, David Wolber

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Android, Where’s My Car?

You parked as close to the stadium as you possibly could, but when the concert ends, you don’t have a clue where your car is. Your friends are equally clueless. Fortunately, you haven’t lost your Android phone, which never forgets anything, and you remember you have the hot new app, “Android, Where’s My Car?” With this app, you click a button when you park your car, and the Android uses its location sensor to record the car’s GPS coordinates and address. Later, when you reopen the app, it gives you directions from where you currently are to the remembered location—problem solved!

image with no caption

What You’ll Learn

This app covers the following concepts:

  • Determining the location of the Android device using the LocationSensor component.

  • Recording data in a database directly on the device using TinyDB.

  • Using the ActivityStarter component to open Google Maps from your app and show directions from one location to another.

Getting Started

Connect to the App Inventor website and start a new project. Name it “AndroidWhere” (project names can’t have spaces) and also set the screen’s title to “Android, Where’s My Car?” Open the Blocks Editor and connect to the phone.

Designing the Components

The user interface for “Android, Where’s My Car?” consists of labels to show your current and remembered locations, and buttons to record a location and show directions to it. You’ll need some ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required