Android Baidu map v3.2.0 obtains the actual address
After Baidu map is upgraded to v3.2.0, the api changes a lot, but the downloaded Demo is not the latest version.
Obtain the detailed address before v3.2.0 as long as: option. setIsNeedAddress (true );
However, after the upgrade, the api changes a lot and the attribute cannot be found. So can only study the use of new APIs, but it is a pity that I haven't found the latest usage for getting the detailed address for a long time (if you know, please let me know !!)
Huang Tianyan is an easy-to-lose man. Finally, he found a class GeoCoder in his mind. He successfully obtained the detailed address, using the following:
GeoCoder coder = GeoCoder. newInstance (); ReverseGeoCodeOption reverseCode = new ReverseGeoCodeOption (); ReverseGeoCodeOption result = reverseCode. location (new LatLng (location. getLatitude (), location. getlongpolling (); coder. reverseGeoCode (result); coder. setOnGetGeoCodeResultListener (new OnGetGeoCoderResultListener () {@ Overridepublic void onGetReverseGeoCodeResult (ReverseGeoCodeResult result) {Log. I ("=", "onGetReverseGeoCodeResult:" + result. getAddress () ;}@ Overridepublic void onGetGeoCodeResult (GeoCodeResult result) {Log. I ("=", "onGetGeoCodeResult:" + result. getAddress ());}});
Note: location is the result returned after positioning. In the BDLocationListener interface !!