FusedLocationProviderClient, This method should only be accessed from tests or within package private scope

Viewed 68

I have a class in my project

public class LocateMe {
  public void locateMe(Activity activity) {
    mLocationClient = new FusedLocationProviderClient(activity);
.....

that uses FusedLocationProviderClient but I keep getting the warning "This method should only be accessed from tests or within package private scope" about the line new FusedLocationProviderClient(activity). I tried to tweak and change things without success.

1 Answers

Use the following way to initialize it instead:

mLocationClient = LocationServices.getFusedLocationProviderClient(getApplicationContext());

or use whatever context you got.

Related