Created
May 23, 2013 06:45
-
-
Save taywils/5633146 to your computer and use it in GitHub Desktop.
loadXMLFromString and GetCurrentLocation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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