I am trying to use the getLocation()
method from GeoFire, and it requires two callbacks. However, I am having Method does not override method from its superclass
error with the @Override onLocationResult()
and onCancelled()
. How to fix this?
Note: My class extends Fragment, and the getLocation()
is within onCreateView()
.
Code:
public class Browse extends Fragment {
...
private DatabaseReference mDatabase; // NEW
private GeoFire geoFire;
private String businessID;
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_browse, container, false);
SharedPreferences businessID1 = getActivity().getSharedPreferences("BUSINESS_ID", Context.MODE_PRIVATE);
businessID = businessID1.getString("businessID", "businessIDNotFound");
mDatabase = FirebaseDatabase.getInstance().getReference().child("geo_fire"); // NEW
GeoFire geoFire = new GeoFire(mDatabase); // NEW
geoFire.getLocation(businessID, new LocationCallback() {
@Override <<<--ERROR HERE !
public void onLocationResult(String key, GeoLocation location) {
if (location != null) {
System.out.println(String.format("The location for key %s is [%f,%f]", key, location.latitude, location.longitude));
} else {
System.out.println(String.format("There is no location for key %s in GeoFire", key));
}
}
@Override <<<--ERROR HERE !
public void onCancelled(DatabaseError databaseError) {
System.err.println("There was an error getting the GeoFire location: " + databaseError);
}
});
return rootView;
}
}
EDIT: My gradle build error:
Error:(90, 13) error: method does not override or implement a method from a supertype
Error:(99, 13) error: method does not override or implement a method from a supertype
Error:(89, 41) error: incompatible types: cannot be converted to com.firebase.geofire.LocationCallback
Dependency: compile 'com.firebase:geofire-android:2.1.1'