Android

ParseGeoPoint features with users Example

Introduction

Parse allows you to associate real-world latitude and longitude coordinates with an object. Adding a ParseGeoPoint to a ParseUser allows your app to estimate the proximity of an user to a reference point. That way, you will be able to easily find out the location of a user, which user is closest to another, show the locations of the users of your app, among other possibilities.

This tutorial explains how to use some of ParseGeoPoint features with users through Back4App.

This is how the example of this tutorial will look like:

Geo Points Example App

At any time, you can access the complete Android Project built with this tutorial at our GitHub repository.

Prerequisites

To complete this tutorial, you need:

Step 1 - Set up a Google API Key

To display the location you will save using ParseGeoPoint, you will need to display a Map. To do that, it’s interesting to use a Google Maps Activity.
In order to create a Google Maps Activity in Android Studio, do the following:

  1. Go to File > New > Google > Google Maps Activity. Then, automatically, it will create a java file, a layout file and a values file corresponding to the Google Maps Activity that you have created.
  2. Go to the created values file (you can do this by accessing app > res > values > google_maps_api.xml), as shown in the image below. This file will give you some instructions on how to get a Google Maps API Key. Basically, you should open the link shown in the image.

    How to access google_maps_api.xml

  3. After opening it, you should login in your Google Account and click on Create a project. While creating the project, Google will enable your API.

    Create a project

  4. After your API is enabled, you will be able to get an API key, to do so click on Create API key.

    Create API Key

  5. Then, your key will be created and you can copy it and paste it in the values file that lead you to this page, in the place where its written YOUR KEY HERE.

    API Key

  6. It’s important to have the following uses-permission in you AndroidManifest.xml file:
    1
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    

    If you created the Google Maps Activity following the instructions above, then it should already be in your manifest, anyway, it’s good to check if this is right, otherwise your app may not collect the user location.

Step 2 -