Search code examples
javaandroidkotlinlocation

Kotlin android use fusedLocationProviderClient for requestLocationUpdates. for commercial use


I do this and I can not find any information for my question can I do this for free in commercial project , it is any limitation ? I try find any information in net but I can not find

public class MainActivity extends AppCompatActivity {

    private FusedLocationProviderClient fusedLocationProviderClient;
    TextView locationTextView;
    LocationRequest locationRequest;

    

        fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
//Instantiating the Location request and setting the priority and the interval I need to update the location.
        locationRequest = locationRequest.create();
        locationRequest.setInterval(100);
        locationRequest.setFastestInterval(50);
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

//instantiating the LocationCallBack
        LocationCallback locationCallback = new LocationCallback() {
            @Override
            public void onLocationResult(LocationResult locationResult) {
                if (locationResult != null) {
                    if (locationResult == null) {
                        return;
                    }
     //Showing the latitude, longitude and accuracy on the home screen.
                    for (Location location : locationResult.getLocations()) {
                        locationTextView.setText(MessageFormat.format("Lat: {0} Long: {1} Accuracy: {2}", location.getLatitude(),
                                location.getLongitude(), location.getAccuracy()));
                    }
                }
            }
        };
        fusedLocationProviderClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper());
    }
}

Can I do this in commercial project for free it is any limitation ?


Solution

  • Yes, the API provided by Google Play Services is free and can be used for commercial purposes.

    For more information, you can refer to the following links:

    API Overview: https://developers.google.com/android/guides/overview

    Location Services: https://developers.google.com/location-context