Using Firebase in a real app – “Here I AM!” GPS Demo app

A previous post introduced the experimental Firebase component in MIT App Inventor. Firebase is a cloud-based database that may be used by App Inventor apps, and which makes exchanging data between users easy. Note: Firebase is experimental and may change in the future. At the present time, there is one Firebase database that is shared by all users. See comments in previous post for more information.

This post uses the GPS location sensors in phones to determine the phone’s position in latitude and longitude. Pressing a button labeled “Send GPS” sends the latitude and longitude coordinates to another phone, which then draws the position on a map. In this way, two phone users can wander about and transmit their location to each other, sending the data through the Firebase cloud database. I named this app “Here I AM!” – pressing the Send GPS tells another user that “I am here!”

User Interface

To use this app, the exact same app should be running on two separate phones. You can run it on a single phone but obviously, you will not be getting updates from anyone else!

The first time you run this app on Android 6, you will be asked to give permission to use location information. Also, be sure to set Location services to on, in Android Settings.

As you move about, press the Send GPS button.  Your latitude and longitude will be sent to Firebase, the other app will be alerted to an updated location, and your location will be displayed on the Google maps on their phone. If they press Send GPS, then their location will be updated on your phone.

The Lat/Long. textbox displays either the latitude, longitude or is prefixed with “THEM:”. “THEM:” means the textbox is showing the other phone’s location; if “THEM:” is not shown, then the textbox is showing your own latitude, longitude.

Screenshot_20160913-102744

Press Retrieve GPS to retrieve and display the latitude/longitude value currently stored in Firebase.

Press Show Map to display the  last retrieved location on the map.

Continue reading