By Harsh Anand
I have made a news app in Android Studio using Java and REST API. I have used Picasso Library for loading images and Retrofit and Gson converter to manage the API requests.
In this app, all the news articles are presented in a Recycler View. The Recycler View displays the news headlines, the corresponding image and the publisher of every news article. If we click on any news article, it will open in a new webView activity. The webView Activity directly takes the user to that particular web page of the news. On the top, we have different categories, and by selecting a particular category, the user will see the news of that particular category.
There is also a search bar present to search for a specific news article.
The news articles are fetched from www.newsapi.org which provides free API keys to get news articles. I have attached a link for the site below.
To show the image of the news article we used a library called Picasso. Picasso is a powerful image downloading and caching library for Android. The Library loads the images of different news articles into the Image View of Recycler View.
In order to manage our requests from API, we use Retrofit Library and Gson converter. Retrofit is a type-safe REST client for Android, developed by Square. The library is used for authenticating and interacting with APIs and sending network requests. Gson is a simple Java-based library that can be used to convert Java Objects into their JSON representation.
Dependancies to implement in module gradle file :
implementation 'com.squareup.picasso:picasso:2.71828' --> Picasso Library implementation
implementation 'com.squareup.retrofit2:retrofit:2.9.0' --> Retrofit Libarry implementation
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' --> Gson converter
Important links :
News API: https://newsapi.org/
Submitted by Harsh Anand (Harsh2106)
Download packets of source code on Coders Packet