Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 978
Nadirspam Avatar asked Nov 14 '25 21:11

Nadirspam


1 Answers

Use the following way to initialize it instead:

mLocationClient = LocationServices.getFusedLocationProviderClient(getApplicationContext());

or use whatever context you got.

like image 180
Asim Avatar answered Nov 17 '25 10:11

Asim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!