I created an Android mobile app that uses Google Maps API to generate a simple map and put a marker on it.
Everything works great in the Android Simulator, however when I use the Android Device, the mapView.getMapAsync does not trigger my OnMapReadyCallback().
Another thing I noted is that I am getting these messages, not sure if they are related to the problem. I tried to update everything in my SDK but these messages just don't go away:
04-07 20:36:30.990 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date. Requires 10298000 but found 9879448
04-07 20:36:30.992 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date. Requires 10298000 but found 9879448
04-07 20:36:30.993 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date. Requires 10298000 but found 9879448
04-07 20:36:30.994 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date. Requires 10298000 but found 9879448
Would you know why? My code is below...
Code:
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
map.addMarker(new MarkerOptions()
.position(new LatLng(asset.latitude, asset.longitude))
.title(asset.networkAssetCode));
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(asset.latitude, asset.longitude), 17));
lastSeenTextView.setText("Last seen: " + asset.datetime);
try {
r.getLocationFromCoordinates(asset.latitude, asset.longitude, new Callback() {
@Override public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override public void onResponse(Call call, Response response) throws IOException {
try (final ResponseBody responseBody = response.body()) {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
Headers responseHeaders = response.headers();
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
}
final String result = responseBody.string();
Log.i("BiTrack", "Google Reverse Geolocation\n" + result);
try {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Json j = new Json();
updateMapView(j.getAddressFromGeolocationCoordinates(result));
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
});