Search code examples
javaandroidgoogle-mapslocationdirection

Getting location of a direction of current location in Android


I want to implement a function that calculates locations' list (longitudes and latitudes) through a direction of my phone. The result can be a rectengular shape which is pointing the corners as locations.

First how can i find the device current direction which means which direction the back camera points ?

Then how can i obtain a list of location information through this direction ?

Thank you


Solution

  • From the documentation of Google Maps Android API, the location data available to an Android device includes the current location of the device pinpointed using a combination of technologies - the direction and method of movement, and whether the device has moved across a predefined geographical boundary, or geofence.

    This is the 3 options that you can do with your app.

    • Using My Location layer that provides a simple way to display the device's location on the map. It does not provide data.

    • Using Google Play services Location API is recommended for all programmatic requests for location data.

    • And using the LocationSource interface allows you to provide a custom location provider.

    By using this, you can also get the different information about the coordinates that you get

    For more information, check this tutorial: