I have spent the better part of a week trying to research how to connect to the USGS Elevation Query Service API via my android app with embarrassing results. The best I have found is from 6-years ago here using now deprecated code. Spoiler - I couldn't get it to work.
Using GPS for elevation is simply too unreliable for my application needs, even after extensive moving averages and low/high pass filtration applied to the data.
Can anyone share their recommendations/code to retrieve elevation via the USGS Elevation Query Service. I can of course provide Latitude and Longitude?
a simple google search on "USGS Elevation Query Service API" pointed to http://ned.usgs.gov/epqs/ (different address from the question you linked. And the API seems extremely straight forward.
Here is an example call to Las Vegas http://nationalmap.gov/epqs/pqs.php?x=36.1251958&y=-115.3150863&output=json&units=Meters
The problem is that as per their website "If unable to find data at the requested point, this service returns -1000000" and I personally couldn't find any location that they have location (tried Las Vegas and San Francisco).
Alternatively, Google have an elevation API, that I can only assume it's pretty damn good considering Google Maps. Here you can see the docs https://developers.google.com/maps/documentation/elevation/start and here is an example query https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034
For the actual call itself, suggest is to use OkHttp (http://square.github.io/okhttp/) or Retrofit (which uses OkHttp) to do threading for you), but a basic code is:
then it's just parse the Json string