Notes: 08. Set Up the Project
The student materials have been reviewed and are updated as of SEPTEMBER 2022.
The second part of the course will use the second sample app called Memories. Memories is an Android application which downloads and displays images in a list. The idea is to be able to share images holding your memories, to a server, where you can safely store them! :]
To do that, you need two applications, instead of one. The first app is the Android app, named Memories. The second app is a Node.js server application, which will act as your local server. It might not make sense to upload to a local server, but for the purposes of this course, it’ll do! :]
To use the projects, you’ll need to do a few things. First, install Node.js on your computer, by heading over to the nodejs.org website, downloading the installer for your operating system, and then running the installer.
It should be easy to install, just follow the instructions for these few steps!
After you install the tool, open the Server folder from the student materials for this course in a terminal, and run the following command:
node app.js
This will run the server application in a terminal, and allow you to connect to the server from within the Android app. Once you’re running the server, you can begin to explore and set up the Android project!
Open the project in Android Studio 3.6 or greater. The Memories project holds several packages to structure its code. The model package holds a few model classes, that represent the data in the app.
You’ll be fetching and displaying images, and those models can be found in that package.
The networking package holds a few classes which should be familiar to you. They are retrofitted classes for networking, from the Android Networking: Fundamentals course. It will help you fetch the images from the server.
The UI package holds the user interface classes. The Memories app has a single Activity, which has two tabs - the Images tab, which shows the images from the server, and the Settings tab, from which you can upload images, or synchronize them.
To be able to fetch images from the local server though, you need to access it through your local IP. To find out what your IP is, open a new terminal tab or window, and run the following command:
ifconfig | grep "inet " | grep -v 127.0.0.1
If you’re using a Windows computer, you should be able to do the same, just replace ifconfig with ipconfig. Once you write that down, you’ll get a list of IP addresses. Copy the addresses one at a time, and open the RetrofitBuilder.kt file in the project. Then replace the following with that address.
Now run the project, and if the request for the image works, and returns a positive response, that is the IP you will use for the server! You you will probably see the hardcoded owl image first, and then an empty screen, because there are no items uploaded to the server yet!
You’ll fix this in the next few episodes!
That’s it! Now you can begin to work on the project, and improve your skills with the WorkManager! :] See you in the next episode.