Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save taywils/5633146 to your computer and use it in GitHub Desktop.
Save taywils/5633146 to your computer and use it in GitHub Desktop.
loadXMLFromString and GetCurrentLocation
public static Document loadXMLFromString(String xml) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(xml));
return builder.parse(is);
}
private class GetCurrentLocation extends AsyncTask<Object, String, Boolean> {
@Override
protected Boolean doInBackground(Object... myLocationObjs) {
if(null != latitude && null != longitude) {
return true;
} else {
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
assert result;
query.append("https://maps.googleapis.com/maps/api/place/nearbysearch/xml?");
query.append("location=" + latitude + "," + longitude + "&");
query.append("radius=" + radius + "&");
query.append("types=" + type + "&");
query.append("sensor=true&"); //Must be true if queried from a device with GPS
query.append("key=" + APIKEY);
new QueryGooglePlaces().execute(query.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment