Android app for retrieving data sent to server in real-time

The way, we use Android HTTP POST & GET request for sending and receiving data from a database(mysql) on server with php as interpreter. The same way, we can deal with ThinkSpeak API for fetching data. In this example, i have used   https://api.thingspeak.com/channels/CHANNEL_ID/feeds/last, replacing CHANNEL_ID with the my Channel.

That is https://thingspeak.com/channels/42256/field/3/last for LDR readings. Below is the exact way in which, i have created object for HTTPGET request.

HttpGet httpget = new HttpGet("https://thingspeak.com/channels/42256/field/3/last");
response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
        if (entity != null) {
                InputStream instream = entity.getContent();
                String result= convertStreamToString(instream);
                
                Log.i("Result",result);
                txtbox2.setText(result);
                instream.close();
            }

And also don’t forget to add permission for internet in Android manifest file.

<uses-permission android:name="android.permission.INTERNET" />

BBB_Thinkspeak APKHere is a snapshot of Main Activity.