Android

Using Parse GeoPoints on your Android app

Introduction

Parse allows you to associate real-world latitude and longitude coordinates with an object. Adding a ParseGeoPoint to a ParseUser, you will be able to easily find out which user is closest to another, show the locations of the users of your app and also store the user’s location information, among other possibilities.

You can also associate a ParseGeoPoint to any ParseObject. For example, if your app is associated with a store with physical affiliates, you will be able to create an activity to show the location of those stores or to show the user which store is closest to him. Another example of this association usage: if your app is a game in which you created ParseObjects to represent characters, adding ParseGeoPoints to these characters would allow them to be shown along the player’s path.

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

After following this tutorial, you will be able to do this:

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:

  • Android Studio.
  • An User Registration - Login App created on Back4App.
  • A real device running Android 4.0 (Ice Cream Sandwich) or newer.
    • Note: It is very likely that the app built with this tutorial won’t run as expected in a virtual device and may even crash because it might not retrieve the current location of the virtual device. So we strongly recommend that you use a real device to run it.

Step 1 - Set up Google API Key

To show the location you stored in a 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, select the Create a project option and click on Continue. 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 uses-permission below in your AndroidManifest.xml file. If you created the Google Maps Activity following the instructions above, then one of these permissions should already be in your manifest, anyway, you’ll need both of them for your app to work properly, so check if they are in your AndroidManifest.xml file, otherwise, insert them on it.
    1
    2
    
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
  7. At the beginning of your MapsActivity, import the following:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    
    // Android Dependencies
    import android.Manifest;
    import android.app.ProgressDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.content.pm.PackageManager;
    import android.location.Location;
    import android.location.LocationManager;
    import android.support.annotation.NonNull;
    import android.support.v4.app.ActivityCompat;
    import android.support.v4.app.FragmentActivity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    // Google Maps Dependencies
    import com.google.android.gms.maps.CameraUpdateFactory;
    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.OnMapReadyCallback;
    import com.google.android.gms.maps.SupportMapFragment;
    import com.google.android.gms.maps.model.BitmapDescriptorFactory;
    import com.google.android.gms.maps.model.LatLng;
    import com.google.android.gms.maps.model.MarkerOptions;
    // Parse Dependencies
    import com.parse.FindCallback;
    import com.parse.ParseException;
    import com.parse.ParseGeoPoint;
    import com.parse.ParseQuery;
    import com.parse.ParseUser;
    // Java dependencies
    import java.util.List;
    

Step 2 - Set up Back4App Dashboard to save user’s location

  1. Go to Back4App website, login, find your app and open its Dashboard.
  2. Go to Core > Browser > User, as shown in the image below.

    User Class

  3. Now, create a new column to save the user’s location. To do so, click on the Edit button in the top right, as shown below.

    Edit Button

  4. Then, click on Add a column.

    Insert Column

  5. In the field What type of data do you want to store?, choose the GeoPoint option.

    Column Type

  6. In the field What should we call it?, type “Location”.

    Column Name

  7. So, click on Add column, as shown in the image below.

    Add a column

  8. Now, your app is able to store location data of users and your User Class in your Back4pp Dashboard should look like this:

    Column Location

Step 3 - Save users current location in your Back4pp Dashboard

  1. Open your MapsActivity and inside the public class MapsActivity define an int called REQUEST_LOCATION with value 1 and a locationManager, as in the following code.
    1
    2
    
    private static final int REQUEST_LOCATION = 1;
    LocationManager locationManager;
    
  2. In the onCreate method create the locationManager, as in the following code.
    1
    
    locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    
  3. To save user’s location in your Back4pp Dashboard, simply implement the following method and call it in your onMapReady method.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    
    private void saveCurrentUserLocation() {
     // requesting permission to get user's location
     if(ActivityCompat.checkSelfPermission(UsersActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(UsersActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){
         ActivityCompat.requestPermissions(UsersActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
     }
     else {
         // getting last know user's location
         Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    
         // checking if the location is null
         if(location != null){
             // if it isn't, save it to Back4App Dashboard
             ParseGeoPoint currentUserLocation = new ParseGeoPoint(location.getLatitude(), location.getLongitude());
    
             ParseUser currentUser = ParseUser.getCurrentUser();
    
             if (currentUser != null) {
                 currentUser.put("Location", currentUserLocation);
                 currentUser.saveInBackground();
             } else {
                 // do something like coming back to the login activity
             }
         }
         else {
             // if it is null, do something like displaying error and coming back to the menu activity
         }
     }
    }
    
  4. It’s really important to implement the following method in order to make saveCurrentUserLocation method works.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){
     super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    
     switch (requestCode){
         case REQUEST_LOCATION:
             saveCurrentUserLocation();
             break;
     }
    }    
    

Step 4 - Retrive user’s location

To retrieve user’s location, you’ll need to find who is the current user, save its location and then return the location saved in your Back4App Dashboard.
In order to do that, implement the following method in your MapsActivity and call it when needed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    /* saving the current user location, using the saveCurrentUserLocation method of Step 3, to avoid
    null pointer exception and also to return the user's most current location */
    saveCurrentUserLocation();
    private ParseGeoPoint getCurrentUserLocation(){

    // finding currentUser
    ParseUser currentUser = ParseUser.getCurrentUser();

    if (currentUser == null) {
        // if it's not possible to find the user, do something like returning to login activity
    }
    // otherwise, return the current user location
    return currentUser.getParseGeoPoint("Location");

}

Step 5 - Showing current user’s location in map

To display user’s location in the map, you’ll need to retrieve user’s location and then create a marker in the map using the information retrieved.
In order to do that, implement the following method in your MapsActivity and call it in the onMapReady method.

1
2
3
4
5
6
7
8
9
10
11
12
private void showCurrentUserInMap(final GoogleMap googleMap){

    // calling retrieve user's location method of Step 4
    ParseGeoPoint currentUserLocation = getCurrentUserLocation();

    // creating a marker in the map showing the current user location
    LatLng currentUser = new LatLng(currentUserLocation.getLatitude(), currentUserLocation.getLongitude());
    googleMap.addMarker(new MarkerOptions().position(currentUser).title(ParseUser.getCurrentUser().getUsername()).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));

    // zoom the map to the currentUserLocation
    googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentUser, 5));
}

Step 6 - Finding the closest user to the current one

  1. Now that you have a bunch of users with spatial coordinates associated, it would be good to find out which user is closest to another. This can be done by using a ParseQuery. First, you’ll need to create a ParseUser query and restrict it with whereNear, informing in which column of the User class on Back4App you are doing the query (in this case the “Location” column) and also inform the reference ParseGeoPoint for the query from which will be found the closest user (in this case the ParseGeoPoint associated to the current user location). The following code do that:
    1
    2
    
     ParseQuery<ParseUser> query = ParseUser.getQuery();
     query.whereNear("Location", getCurrentUserLocation());
    
  2. You can limit the number of results of this query adding to it the restriction setLimit. By default, results are limited to 100. As the whereNear restriction will make the query retrieve an array of users ordered by distance (nearest to farthest) from currentUserLocation, setting the limit of close users to find to the number 2, the list of results of the query will only have two users: the current and the closest user from him. The following code set the limit of results to 2:
    1
    
      query.setLimit(2);
    
  3. Now that you restricted your query, let’s retrieve its results. In order to do that, you will call a findInBackground method and pass as argument a List of users, in which it’ll be stored the results of the query and also a ParseException to handle errors. To avoid errors, don’t forget to clear cached results after the query run. The following code do that:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    query.findInBackground(new FindCallback<ParseUser>() {
       @Override  public void done(List<ParseUser> nearUsers, ParseException e) {
           if (e == null) {
             // do something with the list of results of your query
           } else {
               // handle the error
           }
       }
      });
      ParseQuery.clearAllCachedResults();
    }
    
  4. If no error occurs, you’ll have in the nearUsers list the two closest users to the current user (the actual current user and the closest user from him), now you’ll only have to find who isn’t the current user. To do that, inside the if (e == null) block use the following code:
    1
    2
    3
    4
    5
    6
    7
    8
    
    // avoiding null pointer
    ParseUser closestUser = ParseUser.getCurrentUser();
    // set the closestUser to the one that isn't the current user
    for(int i = 0; i < nearUsers.size(); i++) {
     if(!nearUsers.get(i).getObjectId().equals(ParseUser.getCurrentUser().getObjectId())) {
         closestUser = nearUsers.get(i);
     }
    }
    
  5. Now that you know who is the closest user to the current one you can mesure the distance between them using the distanceInKilometersTo method. In order to do that, use the following code:
    1
    2
    3
    
    // finding and displaying the distance between the current user and the closest user to him
    double distance = getCurrentUserLocation().distanceInKilometersTo(closestUser.getParseGeoPoint("Location"));
    alertDisplayer("We found the closest user from you!", "It's " + closestUser.getUsername() + ". \nYou are " + Math.round (distance * 100.0) / 100.0  + " km from this user.");
    

    The alertDisplayer method used above, is the following:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    private void alertDisplayer(String title,String message){
       android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(UsersActivity.this)
               .setTitle(title)
               .setMessage(message)
               .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                   @Override
                   public void onClick(DialogInterface dialog, int which) {
                       dialog.cancel();
                   }
               });
       android.app.AlertDialog ok = builder.create();
       ok.show();
    }
    
  6. You can also show both users in the map, using the following code:
    1
    2
    3
    4
    5
    6
    7
    
    // showing current user in map, using the method implemented in Step 5
    showCurrentUserInMap(mMap);
    // creating a marker in the map showing the closest user to the current user location, using method implemented in Step 4
    LatLng closestUserLocation = new LatLng(closestUser.getParseGeoPoint("Location").getLatitude(), closestUser.getParseGeoPoint("Location").getLongitude());
    googleMap.addMarker(new MarkerOptions().position(closestUserLocation).title(closestUser.getUsername()).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
    // zoom the map to the currentUserLocation
    googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(closestUserLocation, 3));
    

The complete method that executes all 6 steps above is the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
private void showClosestUser(final GoogleMap googleMap){
    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.whereNear("Location", getCurrentUserLocation());
    // setting the limit of near users to find to 2, you'll have in the nearUsers list only two users: the current user and the closest user from the current
    query.setLimit(2);
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override  public void done(List<ParseUser> nearUsers, ParseException e) {
            if (e == null) {
                // avoiding null pointer
                ParseUser closestUser = ParseUser.getCurrentUser();
                // set the closestUser to the one that isn't the current user
                for(int i = 0; i < nearUsers.size(); i++) {
                    if(!nearUsers.get(i).getObjectId().equals(ParseUser.getCurrentUser().getObjectId())) {
                        closestUser = nearUsers.get(i);
                    }
                }
                // finding and displaying the distance between the current user and the closest user to him, using method implemented in Step 4
                double distance = getCurrentUserLocation().distanceInKilometersTo(closestUser.getParseGeoPoint("Location"));
                alertDisplayer("We found the closest user from you!", "It's " + closestUser.getUsername() + ". \n You are " + Math.round (distance * 100.0) / 100.0  + " km from this user.");
                // showing current user in map, using the method implemented in Step 5
                showCurrentUserInMap(mMap);
                // creating a marker in the map showing the closest user to the current user location
                LatLng closestUserLocation = new LatLng(closestUser.getParseGeoPoint("Location").getLatitude(), closestUser.getParseGeoPoint("Location").getLongitude());
                googleMap.addMarker(new MarkerOptions().position(closestUserLocation).title(closestUser.getUsername()).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
                // zoom the map to the currentUserLocation
                googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(closestUserLocation, 3));
            } else {
                Log.d("store", "Error: " + e.getMessage());
            }
        }
    });
    ParseQuery.clearAllCachedResults();
}

Step 7 - Set up Back4App to associate ParseGeoPoint to ParseObjects

Supose that the example app you are builiding is associated with a group of stores with physical affiliates. It would be interesting to show all the physical affiliates of this store in the map. In order to do so create a Stores class on Back4pp Dashboard, save the existing stores as ParseObjects, their locations and after that the app will be able to query the physical affiliates and display their possitions on the map. The following steps will help you with that.

  1. Go to Back4App website, login, find your app and open its Dashboard.
  2. Go to Core > Browser > Create a class, as shown in the image below.

    Create a class on B4A

  3. In the field What type of class do you need?, choose the Custom option.

    Class Option

  4. In the field What should we call it?, type “Stores” and then click on Create class button.

    Create class button

  5. Then a new class called “Stores” will be shown and you should insert 2 columns on it: a collumn with data type String called Name, as well as another column with data type GeoPoint called Location. If you don’t remember how to create a column, go back to Step 2, there it’s explained how to create a column at Back4App Dashboard. Your class should end up like this:

    Stores Class

  6. Now, fill this class with information. To do so, click on Add a row button in the menu on the top right or in the middle of the page, as shown in the image below.

    Stores Class

  7. Then fill the row with the informations required: the name of the store and its latitude and longitude. After inserting some data, your Stores class should look like the image below. If you want to insert more data, you can click on the Add a row button on the top, or in the + button bellow the last row of data.

    Stores Class with data

Now you are ready to use the location information of the stores in your app.

Step 8 - Display all the stores location on Map

  1. You can show all the stores you added to your class on the MapsActivity by using a ParseQuery. First, you’ll need to create a ParseObject query, informing the name of the Back4pp Dashboard class you want to query (in this case the “Stores” class), and restrict it with whereExists, informing the column of the Store class on Back4App you are doing the query (in this case the “Location” column). The following code do that:
    1
    2
    
      ParseQuery<ParseObject> query = ParseQuery.getQuery("Stores");
      query.whereExists("Location");
    
  2. Now that you restricted your query, let’s retrieve its results. In order to do that, you will call a findInBackground method and pass as argument a List of stores, in which it’ll be stored the results of the query and also a ParseException to handle errors. The whereExists restriction will make only the ParseObjects of the class that have a ParseGeoPoint associated to them indicating their location be stored in the list of stores. To avoid errors, don’t forget to clear cached results after the query run. The following code do that:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    query.findInBackground(new FindCallback<ParseObject>() {
       @Override  public void done(List<ParseObject> stores, ParseException e) {
           if (e == null) {
             // do something with the list of results of your query
           } else {
               // handle the error
           }
       }
      });
      ParseQuery.clearAllCachedResults();
    }
    
  3. If no error occurs, you’ll have in the stores list all the stores with location associated, now you’ll only have to make a loop to display them on the map. To do so, inside the if (e == null) block use the following code.
    1
    2
    3
    4
    
    for(int i = 0; i < stores.size(); i++) {
     LatLng storeLocation = new LatLng(stores.get(i).getParseGeoPoint("Location").getLatitude(), stores.get(i).getParseGeoPoint("Location").getLongitude());
     googleMap.addMarker(new MarkerOptions().position(storeLocation).title(stores.get(i).getString("Name")).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
    }
    

The complete method that executes all 3 steps above is below. Call it on the onMapReady method for it to work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
private void showStoresInMap(final GoogleMap googleMap){

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Stores");
    query.whereExists("Location");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override  public void done(List<ParseObject> stores, ParseException e) {
            if (e == null) {
                for(int i = 0; i < stores.size(); i++) {
                    LatLng storeLocation = new LatLng(stores.get(i).getParseGeoPoint("Location").getLatitude(), stores.get(i).getParseGeoPoint("Location").getLongitude());
                    googleMap.addMarker(new MarkerOptions().position(storeLocation).title(stores.get(i).getString("Name")).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
                }
            } else {
                // handle the error
                Log.d("store", "Error: " + e.getMessage());
            }
        }
    });
    ParseQuery.clearAllCachedResults();
}

Step 9 - Show closest user to a store

  1. Now that you have a bunch of stores with spatial coordinates associated, it would be good to find out which store is closest to a user. This can be done by using a ParseQuery. First, you’ll need to create a ParseObject query, informing the name of the Back4pp Dashboard class you want to query (in this case the “Stores” class), and restrict it with whereNear, informing the column of the Store class on Back4App you are doing the query (in this case the “Location” column). The following code do that:
    1
    2
    
     ParseQuery<ParseObject> query = ParseQuery.getQuery("Stores");
     query.whereNear("Location", getCurrentUserLocation());
    
  2. You can limit the number of results of this query adding to it the restriction setLimit. By default, results are limited to 100. As the whereNear restriction will make the query retrieve an array of users ordered by distance (nearest to farthest) from currentUserLocation, setting the limit of close users to find to the number 1, the list of results of the query will only have one store: the closest to the current user. The following code set the limit of results to 1:
    1
    
      query.setLimit(1);
    
  3. Now that you restricted your query, let’s retrieve its results. In order to do that, you will call a findInBackground method and pass as argument a List of store obejcts, in which it’ll be stored the results of the query and also a ParseException to handle errors. To avoid errors, don’t forget to clear cached results after the query found any result. The following code do that:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    query.findInBackground(new FindCallback<ParseObject>() {
       @Override  public void done(List<ParseObject> nearStores, ParseException e) {
           if (e == null) {
             // do something with the list of results of your query
           } else {
               // handle the error
           }
       }
      });
      ParseQuery.clearAllCachedResults();
    }
    
  4. If no error occurs, you’ll have in the nearStores list the closest store to the current user, now you’ll only have to display it on the MapsActivity. To do that, inside the if (e == null) block use the following code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
      ParseObject closestStore = nearStores.get(0);
      // showing current user location, using the method implemented in Step 5
      showCurrentUserInMap(mMap);
      // finding and displaying the distance between the current user and the closest store to him, using method implemented in Step 4
      double distance = getCurrentUserLocation().distanceInKilometersTo(closestStore.getParseGeoPoint("Location"));
      alertDisplayer("We found the closest store from you!", "It's " + closestStore.getString("Name") + ". \n You are " + Math.round (distance * 100.0) / 100.0  + " km from this store.");
      // creating a marker in the map showing the closest store to the current user
      LatLng closestStoreLocation = new LatLng(closestStore.getParseGeoPoint("Location").getLatitude(), closestStore.getParseGeoPoint("Location").getLongitude());
      googleMap.addMarker(new MarkerOptions().position(closestStoreLocation).title(closestStore.getString("Name")).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
      // zoom the map to the closestStoreLocation
      googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(closestStoreLocation, 3));
    

    The alertDisplayer method used above, is the same of the Step 6 (Finding the closest user to the current one).

The complete method that executes all 4 steps above is the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
private void showClosestStore(final GoogleMap googleMap){
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Stores");
    query.whereNear("Location", getCurrentUserLocation());
    // setting the limit of near stores to 1, you'll have in the nearStores list only one object: the closest store from the current user
    query.setLimit(1);
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override  public void done(List<ParseObject> nearStores, ParseException e) {
            if (e == null) {
                ParseObject closestStore = nearStores.get(0);
                // showing current user location, using the method implemented in Step 5
                showCurrentUserInMap(mMap);
                // finding and displaying the distance between the current user and the closest store to him, using method implemented in Step 4
                double distance = getCurrentUserLocation().distanceInKilometersTo(closestStore.getParseGeoPoint("Location"));
                alertDisplayer("We found the closest store from you!", "It's " + closestStore.getString("Name") + ". \nYou are " + Math.round (distance * 100.0) / 100.0  + " km from this store.");
                // creating a marker in the map showing the closest store to the current user
                LatLng closestStoreLocation = new LatLng(closestStore.getParseGeoPoint("Location").getLatitude(), closestStore.getParseGeoPoint("Location").getLongitude());
                googleMap.addMarker(new MarkerOptions().position(closestStoreLocation).title(closestStore.getString("Name")).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
                // zoom the map to the closestStoreLocation
                googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(closestStoreLocation, 3));
            } else {
                Log.d("store", "Error: " + e.getMessage());
            }
        }
    });

    ParseQuery.clearAllCachedResults();

}

Step 10 - Test your app

  1. Login at Back4App Website.
  2. Find your app and click on Dashboard > Core > Browser > User and create some users with location associated to them to allow the method showClosestUser to work.
  3. Run your app in a real device and sign up an account. Try every feature!
  4. Go back to Back4pp Dashboard and verify if your location is stored in your user row.

It’s done!

At this stage, you can use some features of ParseGeoPoint through Back4App!