I'm trying to start off my Android app journey with an app to display information from a website. The website is from a power draft system that helps me monitor temperatures of the fire and pieces of meat that I'm cooking for long periods of time on my smoker.
The JSON page is found at http://192.168.101.101/stoker.json
on my local network and the data looks like this:
{
"stoker": {
"sensors": [
{
"id": "620000116F01CA30",
"name": "SS2",
"al": 0,
"ta": 66,
"th": 75,
"tl": 65,
"tc": 69.1,
"blower": null
},
{
"id": "E20000116F0CDB30",
"name": "brskt2",
"al": 0,
"ta": 203,
"th": 32,
"tl": 32,
"tc": 71.7,
"blower": null
}
The code that I'm trying to use kept failing, so I added a log to the first step of the process to see what was being found. Here is the code:
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.101.101/stoker.json");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream webs = entity.getContent();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(webs,"iso-8859-1"),4);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
webs.close();
result=sb.toString();
Log.i("log_tag", result);
Here is the result from log during debug:
09-10 08:44:58.375: I/log_tag(748): <body>
09-10 08:44:58.375: I/log_tag(748): <h1>415 Unsupported Type</h1>
09-10 08:44:58.375: I/log_tag(748): </body>
I thought that reading the JSON information would be pretty straightforward, but it obviously isn't. What am I missing here?
At this point I would just like to display the information on my phone and nothing more. Down the road I would like to add more features to the app such as posting changes back to the JSON site and local alarms, but not right now.