Lecture 5 & HW 5: Fragments, Navigation, and Networking

Lecture Demo:

Discussion: YouTube

Discussion Demo:

Starter Code:

Homework Instructions:


Your task this week is to create a simple wallpaper app using Fragments that you can swipe through, a category of apps that sprung up in the heyday of user customization and have been popular ever since. The images in the application will be pulled from the internet using networking and the Pixabay open API. This homework, modeled roughly after them, will give you a rough idea of how the Gallery app functions on your phone. Once again, you'll have a lot of freedom over how this app looks and functions, given a few guidelines below.

We have provided you all with starter code that makes the networking call for you. We want you all to examine this code since networking can be confusing. This week we will give you the code to study and use, but next week you all will generate the code yourselves for the next homework assignment.


1. Your app should allow the user to choose from all 6 of the different wallpapers images from the networking call.

2. Your app should contain one activity that features multiple fragments; however, there need only be one Fragment class used for displaying the available wallpapers. Each fragment should display only one image at a time and should include a way for the user to set the image as their phone's wallpaper.

3. The app should also include a second Fragment class that acts as the home screen. This home screen is reachable from the wallpapers and vice versa. The app's homescreen could have a greeting message on it, be a display of all of the wallpapers in a gallery view or whatever you'd like!

Hints & Resources:

  • It may be easier to depend on the traditional way of tabbing as a means for your navigation or you can use ViewPagers as we talked about during lecture!

  • Take advantage of the Fragment newInstance method with how it takes in parameters and passes them in as arguments to the Fragment. When you create a new fragment there's template arguments but you can adjust them to your needs. Alternatively you can try adapting the Singleton pattern!

  • You can use Glide, an image loading library, to populate your ImageView with the image corresponding to the image URL you receive from the networking call. See the demo for an example of how to use Glide in conjunction with the networking helper code we give you.

  • Setting the Wallpaper in Android requires the following NORMAL permission:

    <uses-permission android:name="android.permission.SET_WALLPAPER" />

Challenge Problems

These are optional challenge problems, and completing each successfully will earn you 1 extra point per problem. If you do attempt a challenge problem, make sure to include a README.txt that states which problem(s) you've attempted!

Spring Szn (1 pt)

  • Modify the GET request to get spring inspired images.

Sincerest Form of Flattery (2 pts)

  • Imitate the Gallery app to it's fullest extent by reading images from folders in local storage (rather than the internal drawable folder or from networking calls)

We'll do it Live! (3 pts)

  • Design and implement a live wallpaper of any sort, from programmatic vector drawing to simple animation.


For this assignment, you may need to figure out a few things on your own. Some classes that may be helpful for this assignment include:

For basic functionality:

Last updated