0

Im having problems with my current code, i don't see what i'm doing wrong. i keep getting the error "no suitable method found for requestLocationUpdates(string,int,in,MapsActivity)

public class MapsActivity extends AppCompatActivity implements LocationListener, OnMapReadyCallback, View.OnClickListener, DirectionCallback, OnMapClickListener, GoogleApiClient.OnConnectionFailedListener {


private LocationManager locationManager;
private Button btnRequestDirection;
GPSTracker gps;
private GoogleMap googleMap;
private String serverKey = "xxx";
private LatLng camera = new LatLng(54.1111, -1.1111);
private LatLng origin = new LatLng(54.1111, -1.1111);
private LatLng destination = new LatLng(54.11, -1.11);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    gps = new GPSTracker(MapsActivity.this);
    long i = 1000;
    long x = 10;
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,i,x, this);


    if (gps.canGetLocation()) {
        camera = new LatLng(gps.getLatitude(), gps.getLongitude());
        origin = camera;


        btnRequestDirection = (Button) findViewById(R.id.btn_request_direction);
        btnRequestDirection.setOnClickListener(this);

        ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(this);
    } else {
        gps.showSettingsAlert();
    }

}

Everything i do the event "onLocationChanged()" never triggers, =/

1 Answers1

0

You need to have a locationListener to listen for a location changes. If you are using 'requestLocationUpdates', you must use 'import android.location.LocationListener'. The standard Android location stuffs is 'android.location'. The com.google.android.gms.location stuff is for use with the FusedLocationProviderApi which is part of Google play services.

Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30