Thursday, March 15, 2018

Android REST Sample Programs

Android REST Sample Programs

Consuming REST API using Retrofit Library in Android - AndroidPub is rest on Android?
Retrofit is a REST Client library (Helper Library) used in Android and Java to create an HTTP request and also to process the HTTP response from a REST API. ... We can also simply say that a RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.Mar 19, 2017

Android Restful Webservice Tutorial – Introduction to RESTful ...
May 1, 2014 - In this post, I will be discussing about creating and invoking RESTful webservice inAndroid applications. This tutorial will be ... RESTful Web services are designed with less dependence on proprietary middleware (for example, an application server) than the SOAP- and WSDL-based kind. As per the ...

Consuming REST API using Retrofit Library in Android - AndroidPub

Mar 19, 2017 - Retrofit is a REST Client library (Helper Library) used in Android and Java to create an HTTP request and also to process the HTTP response from a REST API. It was created by Square, you can also use retrofit to receive data structures other than JSON, for example SimpleXML and Jackson.

Calling RESTful services from your Android app - TechRepublic

Mar 20, 2012 - There are a number of documents available on the web explaining what constitutes aREST service and how to implement one. There are also a number of write-ups explaining how to consume REST services from a client. Yet a common request I see in Android forums is for examples of Java-based ...

Source code for an Android AsyncTask (REST client) example ...

Mar 5, 2018 - This tutorial shares the complete source code for an Android AsyncTask and REST example. ... TextView; public class TestFragment extends Fragment { private static final String TAG = "AATestFragment"; // you'll want to call a REST service, but for basic network testing i use any url //private static final String ...

Creating a Simple Android REST Client Using HTTP-RPC - DZone ...

Dec 29, 2016 - HTTP-RPC, an open-source framework for simplifying the development of RESTapplications, can be used to invoke services provided by JSONPlaceholder.

Android Quickstart

Complete the steps described in the rest of this page, and in about ten minutes you'll have a simple Android application that makes requests to the Drive API.

Weather app uses REST

We can get the current weather details of any city formatted as JSON using the OpenWeatherMap API. In the query string, we pass the city's name and the metric system the results should be in.
For example, to get the current weather information for Canberra, using the metric system, we send a request to
The response we get back from the API looks like this:
Create a new Java class and name it This class is responsible for fetching the weather data from the OpenWeatherMap API.
We use the HttpURLConnection class to make the remote request. The OpenWeatherMap API expects the API key in an HTTP header named x-api-key. This is specified in our request using the setRequestProperty method.
We use a BufferedReader to read the API's response into a StringBuffer. When we have the complete response, we convert it to a JSONObject object.
As you can see in the above response, the JSON data contains a field named cod. Its value is 200 if the request was successful. We use this value to check whether the JSON response has the current weather information or not.

Weather API

Our weather API is simple, clear and free. We also offer higher levels of support, please see our paid plan options. To access the API you need to sign up for an API key if you are on a free or paid plan.

Current weather data

API doc Subscribe
  • Access current weather data for any location including over 200,000 cities
  • Current weather is frequently updated based on global models and data from more than 40,000 weather stations
  • Data is available in JSON, XML, or HTML format
  • Available for Free and all other paid accounts

No comments:

Post a Comment