0

I try to get address from android.location.Geocode. Below is the code:

// Grant whatever permission I think is related

    ActivityCompat.requestPermissions(this,
            new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
                    Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.ACCESS_WIFI_STATE,
            Manifest.permission.ACCESS_NETWORK_STATE,
            Manifest.permission.VIBRATE,
            Manifest.permission.INTERNET},100);

// Request Geocode service. Function: provide an address to addressStr. Expected output: address related information, e.g. latitude, longtitude

import android.location.Geocoder; ...

String addressStr = "#3140-4000 No.3 Rd, Richmond, BC Canada";
Geocoder coder = new Geocoder(mContext);
    List<Address> address;
    address = coder.getFromLocationName(addressStr, 1);
System.out.println(address.size()); 

//Output in mobile device: 0

Result:

  1. Run on a Android device - the address.size() always 0 (PROBLEM here!)
  2. Run on a Android emulator - result normal

coder.isPresent() always return true in above situation.

As the same piece of code working fine in emulator. And it worked in pass few days when I first created this app. I guess google provide free service to emulator, and a certain free quota to actual device. Once the free quota used up, it won't work in actual device anymore. But still work in emulator

Any comment on my guessing?

Brian Mo
  • 15
  • 4
  • I would like to see more code, and Logcat too – Nguyen Quang Anh Apr 04 '16 at 01:29
  • the logcat too large to be posted here. any way I can show you? – Brian Mo Apr 04 '16 at 05:15
  • 04-03 22:07:46.059 32063-32063/jianrongmo.com.comp3617.finalproject.savenet I/HwCust: Constructor found for class android.widget.HwCustTextViewImpl 04-03 22:07:46.088 32063-32213/jianrongmo.com.comp3617.finalproject.savenet I/System: core_booster, getBoosterConfig = false 04-03 22:07:46.543 32063-32225/jianrongmo.com.comp3617.finalproject.savenet I/System: core_booster, getBoosterConfig = false 04-03 22:07:47.520 32063-32240/jianrongmo.com.comp3617.finalproject.savenet I/System: core_booster, getBoosterConfig = false 04-03 22:07:47.612 32063- – Brian Mo Apr 04 '16 at 06:19
  • OK I got it. It seems that it was Geocoder bug. You could review from this : http://stackoverflow.com/questions/4567216/geocoder-getfromlocationname-returns-only-null – Nguyen Quang Anh Apr 05 '16 at 02:02

0 Answers0