Using Volley to request a JSON response
Since JavaScript Object Notation (JSON) is probably the most common data-interchange format, you'll likely find yourself needing to call a JSON web service. (If you are unfamiliar with JSON, review the link at the end of this recipe.) This recipe will demonstrate how to make a JSON Request using Volley.
Getting ready
Create a new project in Android Studio and call it JSONRequest
. Use the default Phone & Tablet option and select Empty Activity when prompted for Activity Type.
This recipe will be using the Volley setup as described in Getting started with Volley for Internet requests. Follow steps 1-5 to add Volley to your new project.
How to do it...
With Volley added to your project as described previously, follow these steps:
- Open
activity_main.xml
and replace the existingTextView
with the following XML:<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content...