0
我創建了一個Android移動應用程序,它使用Google Maps API生成一個簡單的地圖並在其上放置一個標記。Android谷歌地圖OnMapReadyCallback()沒有發生在設備上(作品模擬器)
在Android模擬器中一切都很好,但是當我使用Android設備時,mapView.getMapAsync不會觸發我的OnMapReadyCallback()。
我注意到的另一件事是我收到這些消息,不知道它們是否與問題有關。我試圖更新SDK中的所有內容,但這些消息不會消失:
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
您知道爲什麼嗎?我的代碼如下...
代碼:
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();
}
}
});
做您使用調試證書運行應用程序?還是你使用了發行證書? –
我是Android新手,這是我第一次在實際設備上運行。我不知道這些是什麼。你可以解釋嗎?也許這是我的問題,然後......謝謝! – user1060551
你應該真的在你的類上實現'OnMapReadyCallback'。 –