Android
1:52 pm
How to get String in response using Retrofit 2? Retrofit Android example
Today we are going to look at another awesome library Retrofit
to make the http calls. Retrofit is denitely the better alternative to volley
in terms of ease of use, performance, extensibility and other things. It is a type-safe REST client for Android
built by Square. Using this tool android developer can make all network stuff much
more easier. As an example, we are going to download some json and show it in
RecyclerView as a list.
Retrofit get api example |
Follow
those steps:-
1.Add the permission to access
internet in the AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="demo.mukesh.app.com.myapplication">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>