how to get value "A Salam St, Sib, Oman" in string placename in android application. json response attached as image . please check {
String URL="https://maps.googleapis.com/maps/api/geocode/json?latlng="+myLat+","+myLong+"&&key=XXX";
RequestQueue requestQueue= Volley.newRequestQueue(MercahntUpdate.this);
//etMID.setText("");
JsonObjectRequest objectRequest=new JsonObjectRequest(
Request.Method.GET, URL, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.e("success",response.toString());
String loudScreaming = response.optJSONArray("results[0].address_components.formatted_address").toString();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("error",error.toString());
}
}
);
Drop the raw Json into http://www.jsonschema2pojo.org/ and create a class to handle serialization. Then you would be able to access the formatted_address
from a getter.
the below PSEUDO code would go into your onResponse
for(Result res : response.results){
res.getFormattedAddress();
}