Skip to main content

Geocoder is not working, instead use google maps

I noticed that Geocoder does not work for a month in my app. I tested it different simulator and device. But i never get a address. After test i search another method for find address. While i search this, i notice i am not alone with geocoder issue. Other developers use a work arround. I added a few line of code for encoding UTF-8 characters.

public static List<Address> getStringFromLocation(double lat, double lng)
        throws ClientProtocolException, IOException, JSONException {
String address = String.format(Locale.ENGLISH, "$f,%2$f&sensor=false", lat, lng);
HttpGet httpGet = new HttpGet(address);
HttpClient client = new DefaultHttpClient();

client.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
HttpResponse response;
StringBuilder stringBuilder = new StringBuilder();
List<Address> retList = null
response = client.execute(httpGet);
HttpEntity entity = response.getEntity();

InputStream stream = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
String line;
while ((line = reader.readLine()) != null)
    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.getDefault());
    addr.setAddressLine(0, indiStr);
return retList;

I hope you can use this helpful. And i update Show The Way. 
Here is change log;
FC Bugs fixed
No location issue solved
Unnecessary dialogs removed
No address issue solved
Reduce ads show
Refactor location code
Library update

If you find my blog or apps usefull, please consider donation.



Popular posts from this blog

How to change position of MyLocationButton on new Map API v2 - 2

In my previuos post[1], i mention a workaround for changing buttons on Google Map which we use with google services. It is good to know they listen developers and make their products more development friendly. (I hope it goes like that way all the time and all the product lines of Google) Now we have a method for setting padding of map. It is add padding to useful area of map. We can see full screen map but with padding we can use prefered area of it. It is good for overlay action bar and other things on map view. [ 2] They write a blog and take a video about it. Read blog and watch video if you are using google map in your app :) [3] And finally, They add this method because of this issue. That means, if you find a bug or want extra feature from and api, write to google via this issue tracking system. [1] [2] [3] http://googlegeodeve

How to set alarm to show a notification at future date with AlarmManager?

Lets assume you want to do a job a future time or show a notification at a selected time. AlarmManager can help to send an intent in future time. First we need to select date, Lets create a date in 2050, Calendar calendar = Calendar. getInstance () ; calendar.set(Calendar. YEAR , 2050 ) ; Date date = calendar.getTime() ; For showing notification we need a service. public class AlarmReceiver extends Service { public AlarmReceiver() { } @Override public IBinder onBind (Intent intent) { } } Add service to Manifest.xml <service android :name= "com.kozaxinan.example.alarm.AlarmReceiver" android :enabled= "true" android :exported= "true" > </service> We will modify AlarmReceiver for sending notification. But first we need to register a alarm. AlarmManager alarmManager = (AlarmManager) getSystemService( ALARM_SERVICE ) ; Intent intent = new Intent( this, AlarmReceiver. class ) ; intent.putExtra( &q

Finally I released my First Game; The Red Button

Finally I released  "The Red Button Don't Touch It" . My First Game for Android. Game has only one objective; be fast enough to react and click the green button. Playstore Link : Please don't hesitate to give me feedback!