我正在尝试通过单击按钮来查找 android 设备的当前位置。Geocoder 在 UIThread 中运行时会挂起 UI,因此我必须在后台线程上运行它。我是 AsyncTasks 的新手。到目前为止,我有这行代码,但我真的不知道参数、进度、结果必须是什么。我不想输入任何东西,或者没有任何进展,只是结果是一个表示当前地址的字符串。
先感谢您。
    public void onClickGetCCity(View v){
    new GetCurrentCity.execute();
    }  
       private class GetCurrentCity extends AsyncTask<Void, Void, Void>{
        @Override
                protected void doInBackground(Void... params) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROV
IDER);
                double longitude = location.getLongitude();
                double latitude = location.getLatitude();
                if(Geocoder.isPresent()){
                    Geocoder gcd = new Geocoder(getApplicationContext(), Locale.getDefault());
                    try {
                        List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1);
                        if(addresses != null) {
                            Address returnedAddress = addresses.get(0);
                            for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {
                           strReturnedAddress = (returnedAddress.getAddressLine(i)).toString();