我正在使用Google Places API,对于以下代码,它显示了诸如Required packagename.Model.location和Found android.location之类的内容:
@Override
public void onLocationChanged(android.location.Location location) {
mLastLocation = location;
if (mMarker != null)
mMarker.remove();
latitude = location.getLatitude();
longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude,longitude);
MarkerOptions markerOptions = new MarkerOptions()
.position(latLng)
.title("Your Position")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
mMarker = mMap.addMarker(markerOptions);
//Move Camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
if (mGoogleApiClient != null)
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
如果我这样更改方法:
public void onLocationChanged(Location location)
然后,它表明该方法未覆盖其超类。 Model.Location类的代码为:
public class Location {
private String lng;
private String lat;
public String getLng ()
{
return lng;
}
public void setLng (String lng)
{
this.lng = lng;
}
public String getLat ()
{
return lat;
}
public void setLat (String lat)
{
this.lat = lat;
}
@Override
public String toString()
{
return "ClassPojo [lng = "+lng+", lat = "+lat+"]";
}
}
我面临的错误:
C:\Users\sadma\AndroidStudioProjects\RateLocalBusiness\app\src\main\java\com\example\sadma\ratelocalbusiness\MapsActivity.java:152: error: incompatible types: android.location.Location cannot be converted to com.example.sadma.ratelocalbusiness.Model.Location
mLastLocation = location;
^
Note: C:\Users\sadma\AndroidStudioProjects\RateLocalBusiness\app\src\main\java\com\example\sadma\ratelocalbusiness\MapsActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.