2017-04-26 3 views
0

나는 Android 개발자이며 Uber, Careem 등의 애플리케이션에서 작업 중입니다.Google지도를 만드는 방법은 특정 국가에서 작동합니다. - Android

Google지도를 사용하여 특정 친구에게 자신의 마커를 설정할 수있는 기능이 있습니다.

여기 내 문제는 사우디 아라비아와 제다 도시에서만 적용됩니다. 나는 다른 어떤 국가 나 도시도 위와 같은 것을 기대하지 않는다.

사용자가 마커를 드롭 다운하여 팝업을 표시하거나 우리가 아직이 영역을 지원하지 않는다고 알려주는 해결책이 필요합니다.

해결책이 있습니까? 잘못된 좌표에 앞뒤로 아래로 사용자 드롭은, 팝업 메시지 뭔가가 우리가 아직이 분야를 지원하지 않는 것을 그에게 말하고 표시됩니다 때

덕분에,

+0

나는 해결책이 필요합니다. –

+0

나는 당신이 jadda 센터 * jadda 거리에 대한 경도와 위도를 가져야한다고 생각한다. 이제 jadda 거리가있다 ... 이제이 위치 바깥에있는 사용자가 당신의 메시지를 팝업한다면 ... 내가 가정 한 전문 솔루션이 아니다. 그러나 그것은 당신을 도울지도 모른다. – Ibrahim

답변

0
/** 
* Get ISO 3166-1 alpha-2 country code for this device (or null if not available) 
* @param context Context reference to get the TelephonyManager instance from 
* @return country code or null 
*/ 
public static String getUserCountry(Context context) { 
    try { 
     final TelephonyManager mTelephonyManager= (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); 
     final String simCountry = mTelephonyManager.getSimCountryIso(); 
     if (simCountry != null && simCountry.length() == 2) { // SIM country code is available 
      return simCountry.toLowerCase(Locale.US); 
     } 
     else if (mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable) 
      String networkCountry = mTelephonyManager.getNetworkCountryIso(); 
      if (networkCountry != null && networkCountry.length() == 2) { // network country code is available 
       return networkCountry.toLowerCase(Locale.US); 
      } 
     } 
    } 
    catch (Exception e) { } 
    return null; 
}