5

때때로 내 신청서의 Service Not Available 예외를 충족합니다. 대부분의 경우 문제가 없습니다. 그러나 때때로 그것은 일어난다. (이 앱은 아직 개발 중입니다)역 지오 코딩 - 서비스를 사용할 수 없음 - 명확한 문제를 해결하지 못하는 기기를 다시 시작합니다. - 내 수동 역 지오 코딩을 비평합니다.

핸드셋을 다시 시작하는 방법은 입니다. Relevant Issue38009 on support forums. 하지만 내가이 말을 이해하면 장치를 재부팅하면 영원히 문제가 해결된다는 것입니다..

이 정보가 맞습니까?
내 경우 버그가 반환 될 수 있습니다 (빈도 : 한두 번 한 달에이 앱에서 풀 타임으로 &이라고 생각합니다).

에서 지오 코더를 다시 시작하는 방법은 입니까?

내가 가진 유일한 해결책은 아래의 주소를 "수동으로"가져 오는 경우를 대비 한 대안 솔루션을 제공하는 것입니다. 더 나아 졌니?

Dbg.d(TAG, "=== address_info FetchLocationTask - doInBackground"); 
new Thread(new Runnable() { 

    @Override 
    public void run() { 
     Looper.prepare(); 
     mHandler = new Handler(); 
     Looper.loop(); 
    } 
}).start(); 

    /** 
    * Implementation of a second method in case of failure: 
    * 
    */ 
    double lat = Double.parseDouble(args[0]); 
    double lng = Double.parseDouble(args[1]); 
    String address = String.format(Locale.ENGLISH, 
      "http://maps.googleapis.com/maps/api/geocode/json?latlng="+Double.toString(lat)+","+Double.toString(lng)+"&sensor=true&language="+Locale.getDefault().getCountry(), lat, lng); 
    Dbg.d(TAG, "fetching path : "+ address); 


    HttpGet httpGet = new HttpGet(address); 
    HttpClient client = new DefaultHttpClient(); 
    HttpResponse response; 
    StringBuilder stringBuilder = new StringBuilder(); 

    List<Address> retList = null; 

    try { 
     response = client.execute(httpGet); 
     HttpEntity entity = response.getEntity(); 
     InputStream stream = entity.getContent(); 
     int b; 
     while ((b = stream.read()) != -1) { 
      stringBuilder.append((char) b); 
     } 

     JSONObject jsonObject = new JSONObject(); 
     jsonObject = new JSONObject(stringBuilder.toString()); 


     retList = new ArrayList<Address>(); 


     if("OK".equalsIgnoreCase(jsonObject.getString("status"))){ 
      JSONArray results = jsonObject.getJSONArray("results"); 
      for (int i=0;i<results.length();i++) { 
       JSONObject result = results.getJSONObject(i); 
       String indiStr = result.getString("formatted_address"); 
       Address addr = new Address(Locale.ITALY); 
       addr.setAddressLine(0, indiStr); 
       Dbg.d(TAG, "adresse :"+addr.toString()); 
       retList.add(addr); 
      } 
     } 


    } catch (ClientProtocolException e) { 
     Dbg.e(TAG, "Error calling Google geocode webservice.", e); 
    } catch (IOException e) { 
     Dbg.e(TAG, "Error calling Google geocode webservice.", e); 
    } catch (JSONException e) { 
     Dbg.e(TAG, "Error parsing Google geocode webservice response.", e); 
    } 

    JSONObject jObj = new JSONObject(); 

    boolean found = false; 

    if (retList.size() > 0) { 

     Address a = retList.get(0); 

     String name = a.getAddressLine(0); 
     String city = a.getLocality(); 
     String postalCode = a.getPostalCode(); 
     String country = a.getCountryName(); 

     if (!TextUtils.isEmpty(name)) { 
      JsonUtils.setSringInJson(jObj, BookLocation.ADDRESS_NAME_KEY, name); 
      found = true; 
     } 
     if (!TextUtils.isEmpty(postalCode)) { 
      JsonUtils.setSringInJson(jObj, BookLocation.ADDRESS_POSTAL_CODE_KEY, postalCode); 
      found = true; 
     } 
     if (!TextUtils.isEmpty(city)) { 
      JsonUtils.setSringInJson(jObj, BookLocation.ADDRESS_CITY_KEY, city); 
      found = true; 
     } 
     if (!TextUtils.isEmpty(country)) { 
      JsonUtils.setSringInJson(jObj, BookLocation.ADDRESS_COUNTRY_KEY, country); 
      found = true; 
     } 

    } 
    mHandler.getLooper().quit(); 
    if (found) { 
     return jObj; 
    } else return null; 
+0

링크가 여기에 표시되어야합니다. https://code.google.com/p/android/issues/detail?id=38009 문제를 읽고 _no_부터 재부팅해도 문제가 영구적으로 해결되지 않습니다. 실제로 –

+0

을 수정하십시오. – Poutrathor

답변

0

상태 @ 마이크에서 링크 : 동기화가 모두 필요 지오 핸들러와 AsyncTask를 클래스를 사용하여 대체 구현 - 어떤 서비스가 우리가 URL에서 주소를 얻을 수있는 경우와 같이합니다. 불행히도 @Poutrathor에서 제공 할 수있는 유일한 해결책입니다.

또한 우리가 재부팅 그러나 적어도 그것에 대해 해결책을 알리기 위해 사용자를 강요 할 수 여기 Service not Available - Geocoder Android

참조하십시오.

+1

안녕하세요! 귀하의 링크가 실패했습니다. 다음과 같이 닫으십시오 : [Service not Available - Geocoder Android] (링크) – Poutrathor

+0

thanks! @Poutrathor – MOSO