Android:OnFocusChangeListener-Latitude and longitude changes when editing the address
<p>In my layout i have three edittext feilds, i am getting the address , 
latitude and logitude into those edittexts based on search. i am implementing OnFocusChangeListener on address edittext,i am facing issue when i am trying to edit the address, i am loosing the gps details(lat and lng) when editing and changing the focus.</p>

<pre><code> address.setOnFocusChangeListener(new OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) {
                        v.setBackgroundResource(R.drawable.textselected);
                    } else {
                        v.setBackgroundResource(R.drawable.textborder);
                    }

                    StringBuffer myAddress = new StringBuffer();
                    if (address.getText().toString() != null
                            &amp;&amp; !address.getText().toString().trim().equals("")) {
                        myAddress.append(address.getText().toString());
                    }
                    if (addressCity.getText().toString() != null
                            &amp;&amp; !addressCity.getText().toString().trim().equals("")) {
                        myAddress.append(",");
                        myAddress.append(addressCity.getText().toString());
                    }
                    if (addressState.getText().toString() != null
                            &amp;&amp; !addressState.getText().toString().trim().equals("")) {
                        myAddress.append(",");
                        myAddress.append(addressState.getText().toString());
                    }

                    if (addressPostalCode.getText().toString() != null
                            &amp;&amp; !addressPostalCode.getText().toString().trim()
                                    .equals("")) {
                        myAddress.append(",");
                        myAddress.append(addressPostalCode.getText().toString());
                    }

                    String newAddress = myAddress.toString();

                    if (newAddress != null &amp;&amp; !newAddress.trim().equals("")) {
                        if (!hasFocus) {
                            try {
                                HashMap&lt;String, Double&gt; gpsMap = FavoriteUtils
                                        .getGpsDetails(EditPABActivity.this,
                                                newAddress);
                                if (!gpsMap.isEmpty()) {
                                    layoutUtils.setLatitude(gpsMap.get("latitude")
                                            + "");
                                    layoutUtils.setLongitude(gpsMap
                                            .get("longitude") + "");
                                }
                            } catch (Exception e) {
                                layoutUtils.setLatitude("0.0");
                                layoutUtils.setLongitude("0.0");}}}}});
</code></pre>

<p>after editing the address and changing the focus , iam not able to get the gps details, below is how i am getting gpsdetails</p>

<pre><code>public static HashMap&lt;String, Double&gt; getGpsDetails(Activity activity,
            String address) {
        HashMap&lt;String, Double&gt; gpsMap = new HashMap&lt;String, Double&gt;(2);
        if (new Utils().isConnectionAvailable(activity)) {
            if (address != null &amp;&amp; !address.trim().equals("")) {
                Geocoder geoCoder = new Geocoder(activity, Locale.getDefault());
                double latitude = 0;
                double longitude = 0;
                int status = 0;
                while (status &lt; 5) {
                    try {
                        List&lt;Address&gt; addresses = geoCoder.getFromLocationName(
                                address, 1);
                        if (addresses.size() &gt; 0) {
                            for (int i = 0; i &lt; addresses.size(); i++) {
                                latitude = addresses.get(i).getLatitude();
                                longitude = addresses.get(i).getLongitude();
                                Log.d(TAG,
                                        "createDiloag-----&gt;"
                                                + (addresses.get(i)
                                                        .getLatitude() * 1E6)
                                                + "");
                                Log.d(TAG, "createDiloag-----&gt;"
                                        + addresses.get(i).getLatitude());
                                Log.d(TAG, "createDiloag-----&gt;" + latitude);
                            }
                        }
                        if (latitude != 0 &amp;&amp; longitude != 0) {
                            status = 5;
                        }
                        status++;
                    } catch (Exception e) {
                        Log.d(TAG, "getGpsDetails-----&gt;", e);
                        status++;
                    }
                }
                try {
                    gpsMap.put("latitude", latitude);
                    gpsMap.put("longitude", longitude);
                    Log.d(TAG, "createDiloag-----&gt;latitude--&gt;" + latitude);
                    Log.d(TAG, "createDiloag-----&gt;longitude--&gt;" + longitude);
                    if (latitude == 0 &amp;&amp; longitude == 0 &amp;&amp; status == 5) {
                        Toast.makeText(activity, R.string.unavailablegps,
                                Toast.LENGTH_LONG).show();
                    }} catch (Exception e) {}}}
        return gpsMap;}
</code></pre>

<p>i want the gps details stay even after editing the address. Anyhelp is appreciated.</p>
