不可同时呼吁地理coder.getFromLocation服务()地理、coder、getFromLocation

2023-09-11 12:30:13 作者:闭眸

我知道,有时谷歌后端服务可能无法使用。

I know sometimes google back-end service might not be available.

因此​​,一个解决办法可能是循环,直到我得到的数据。

Hence a solution might be to loop until i get the data.

private class getLocationDetails extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        Log.d("looping", "" + count + "");
        count++;
        double lat = Double.parseDouble(params[0]);
        double lng = Double.parseDouble(params[1]);
        List<Address> addresses = null;
        try {

            Geocoder gCoder = new Geocoder(ImageAndLocationActivity.this,
                    Locale.getDefault());
            addresses = gCoder.getFromLocation(lat, lng, 1);
            Address addr = addresses.get(0);
            user_country = addr.getCountryName();
            user_city = addr.getLocality();
            user_district = addr.getSubAdminArea();

            if (user_city == null) {

                user_city = user_district;
            }
        } catch (Exception e) {

            Log.e("Exception in getLocationDetails - ", e.getMessage());
            return null;
        }

        return "";
    }

    @Override
    protected void onPostExecute(String result) {

        if (result != null) {

            Log.d("user_city = ", "" + user_city);
        } else {

            new getLocationDetails().execute(CurrentLat + "", CurrentLng
                    + "");
        }
    }

    @Override
    protected void onPreExecute() {

    }

    @Override
    protected void onProgressUpdate(Void... values) {

    }
}

但我不能够得到的位置在所有的:

But i am not able to get the location at all:

LogCat中:

02-27 16:29:49.568: D/looping(10966): 110355
02-27 16:29:49.568: E/Exception in getLocationDetails -(10966): Service not Available
02-27 16:29:49.573: D/looping(10966): 110356
02-27 16:29:49.573: E/Exception in getLocationDetails -(10966): Service not Available
02-27 16:29:49.573: D/looping(10966): 110357
02-27 16:29:49.573: E/Exception in getLocationDetails -(10966): Service not Available

和ofcourse我已经添加了所有需要的权限:

and ofcourse i have added all the needed permissions:

<uses-permission android:name="android.permission.INTERNET" />

我在想这个三星Galaxy Note的GT-N7000(4.0.4版本)

我失去了任何设置?相关设备或应用程序?或者,这通常会发生什么?如果是没有更好的解决方案来解决这个??

Am i missing any settings? related to device or application ? Or this usually happens? If so any better solution to resolve this??

感谢您

推荐答案

为什么地理codeR 不被工作实际的原因是因为 NetworkLocator 在行动被杀害。可能是由于较少的内存或者你使用任务管理器杀死所有的服务?

The actual reason why Geocoder was not working is because the NetworkLocator was killed in action. Probably due to less memory or maybe you used the Task Manager to kill all services?

我不知道,但是这是一个猜测。我以前见过这个。去年,我写了一个重新连接的机制来加载NetworkLocator.apk并绑定到地理coderService 。我想,这种变化并没有合并到软糖所以这个问题仍然存在。

I'm not sure but this is a guess. I've seen this before. Last year I wrote a reconnect mechanism to load the NetworkLocator.apk and bind to the GeocoderService. I think this change has not merged into JellyBean so this problem persists.

有可以仅通过重新引导解决。 (该 NetworkLocationService 在引导加载)

It can be only solved by reboot. (The NetworkLocationService is loaded at boot)

编辑:你不会看到JBP或KK这个问题,该服务被移动到playstore应用程序。

You won't see this problem in JBP or KK, this service is moved into the playstore app .

 
精彩推荐
图片推荐