Google지도 Android API V2를 사용하는 경우 내 주 활동에 다음 코드를 사용하여 Google Play 서비스가 설치되어 있는지 확인하기 위해 Google Play Services setup documentation을 따르고 있습니다.Google지도 Android API V2 기기에 GoogleMaps가 설치되어 있는지 확인합니다.
@Override
public void onResume()
{
checkGooglePlayServicesAvailability();
super.onResume();
}
public void checkGooglePlayServicesAvailability()
{
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(resultCode != ConnectionResult.SUCCESS)
{
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 69);
dialog.setCancelable(false);
dialog.setOnDismissListener(getOnDismissListener());
dialog.show();
}
Log.d("GooglePlayServicesUtil Check", "Result is: " + resultCode);
}
잘 작동합니다. 그러나, 내가 깔아 놓은 오래된 Android 휴대 전화 중 일부 (주로 2.2 버전)에는 GooglePlayService와 Google지도 앱이 모두 누락되어 있음을 알았습니다.
LogCat에서이 오류를보고합니다 : Google지도 Android API : Google지도 응용 프로그램이 없습니다.
질문 질문 - 기기에서 Google지도를 사용할 수 있는지 위와 유사한 검사를 수행하려면 어떻게해야합니까? 둘째, 사용자가 이미 Google지도를 설치 한 경우 설치된 버전이 Android Maps API V2와 호환되는지 확인해야합니다.
업데이트 여기에서 onCreate의 말()에서 호출 내 setupMapIfNeeded() 방법이다.
private void setUpMapIfNeeded()
{
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null)
{
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.basicMap)).getMap();
if (mMap != null)
{
mMap.setLocationSource(this);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(44.9800, -93.2636), 10.0f));
setUpMap();
}
else
{
//THIS CODE NEVER EXECUTES - mMap is non-null even when Google Maps are not installed
MapConstants.showOkDialogWithText(this, R.string.installGoogleMaps);
}
}
}
난 그냥 물어 수 rs? – luiscvalmeida
@luiscvalmeida 69는 요청 코드 일뿐입니다 (제가 선택한 것입니다). http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#getErrorDialog에서 getErrorDialog 메소드를 참조하십시오. – DiscDev