Ad

Saturday 31 July 2021

Build A Wallpaper App By Using Volley And Unsplash API

We are going to learn how to build a Wallpaper app with Volley library and Unsplash API (free).We are creating a full Wallpaper Android app. which is a good Android project. After that you can create your own Wallpaper App. So let’s get started coding,

If you like to learn via video then you can watch it on Youtube, Or you can watch the demo at least


The wallpaper Android app we will be creating will contain a vertical scrolling RecyclerView. This RecyclerView will contain a list of imageview for the each wallpaper. The wallpaper imageview will show an image of the wallpaper.

Note : you need ACCESS KEY/API KEY to fetch Wallpaper. You get this on Unsplash.com. Signup and create account. 

Take a look at a screenshot of wallpaper Android App we will be creating below.
Build A Wallpaper App By Using Volley And Unsplash API
Build A Wallpaper App By Using Volley And Unsplash API

Things covered in this blog:

  • Fetch data from an Unsplash API using by Volley 
  • How to show images in grid view
  • How to create RecyclerView and Adapter

Step 1: Requesting Permissions in the Android Manifest

We will need to request the following two Android permissions in the manifest file for our Android wallpaper app to work.


As will be loading images for the internet to be used for selecting the wallpaper we will need to the INTERNET permission enabled.
To set an image as the wallpaper on the Android device we will require the SET_WALLPAPER permission to be granted in the Android manifest.

Step 2: Downloading Gradle Dependencies

In this tutorial for building an app to set the wallpaper on the device we will be using Volley library to fetch the JSON data in our Android app. We will also be using the image loading library Glide to load wallpaper images from the internet.

See the sample app level build.gradle containing the dependencies for the Volley Library and Glide.

Step 3: Setting up RecyclerView to Display a Gallery of Wallpapers

In this section of the tutorial we will be setting up an activity that will contain a RecyclerView. This RecyclerView will show a imageview for each wallpaper, each imageview will contain an image of the wallpaper (loaded using Glide).

We will first create a model class for the Wallpaper that will contain a String for the URI of the image. See the code sample for the Wallpaper class below.


Now we will create the lmage_list layout to inflate the RecyclerView of the wallpapers.


Step 4: RecyclerView Adapter and ViewHolder

Next we will create the RecyclerView adapter class for showing the wallpapers in the RecyclerView. See the code sample for the ImageAdapter class below.

Step 5: Using Volley and Fetch the wallpaper urls

You will see in the onCreate(…) method of the activty class we are creating a List of Wallpaper objects using wallpaper images from the free to use stock photo website Unsplash.com. Once the list is created we create the ImageAdapter and pass the list of wallpapers to the custom RecyclerView adapter using the setWallpapers(List<Wallpaper>) method.

In the onCreateView(…) method of the activity we set up the RecylcerView by setting the Gridlayout manager and the adapter containing the list of wallpapers objects.

After Using Volley library we fetch JSON data form unsplash API.Use the JSONArreryRequest we get all image urls and add this in our ImageModel list.

See the code sample for the ImageListActivity class below.



ImageListActivity.xml




How To Add Infinite Scrolling In RecyclerView

This tutorial will illustrate how to implement infinite scrolling in Android, where the data should be load automatically as the user scrolls down. We can load a data when we have finished scrolling. Add recyclerview setOnScrollListener .


If you like to learn via video then you can watch it on Youtube.


How To Add Custom Search Bar For Search Wallpapers

Build A Wallpaper App By Using Volley And Unsplash API
Build A Wallpaper App By Using Volley And Unsplash API

This tutorial will illustrate how to implement custom searchBar for searching wallpapers. We need to first modify the urls and a new activity(SearchActivity). We also need a editText where user typing any text. Let's see in coding.

Add this code in ImageListActivity.xml


Add this code in SerachActivity.xml


and the final code SearchActivity.class


Serach Background(@drawable/search_background)


If you like to learn via video then you can watch it on Youtube.

How To Add Set Wallpaper And Zoom Functionality Using By PhotoView Library 

Build A Wallpaper App By Using Volley And Unsplash API
Build A Wallpaper App By Using Volley And Unsplash API



In this tutorial for building an app to set the wallpaper on the device. To impelement that functionality we need a new activity. We hope to have the ability to zoom to look into each image and view them on full screen. Not only that, after zoom, we want to drag around given the image might be bigger than the device view. And ideally, we want the ability to fling the zoomed-in image from one end to the other. Should we implement all that?  So let’s get started coding, 


To use it, just make use you access to the maven repo by adding this to your project build.gradle


Then add the library at app build.gradle


FULLIMAGEVIEW.xml


FULLIMAGEVIEW.java


If you like to learn via video then you can watch it on Youtube.

For The Latest #Auto #News and #Reviews, Follow My Support Tech On Twitter, Facebook, And Subscribe To Our Email Notification.

No comments:

Post a Comment