Part of Android Development - ISMIN 2020
Course followed by students of Mines St Etienne, ISMIN - M2 Computer Science.
The goal is to link the app to a Rest API using Retrofit:
You can either use:
- your own Book Rest API
- a generic one accessible on: https://bookshelf-gme.cleverapps.io/books
Preparatory work:
- Copy everything from previous TP (except the README)
First:
- Add retrofit dependencies (see course slides) to
build.gradle
- Add internet permission in
AndroidManifest
Then:
-
Create a
BookService
interface -
Add a
getAllBooks
function with annotations matching the API -
Create an instance of
retrofit
and instantiateBookService
with it inMainActivity
-
Call
getAllBooks
in theonCreate
function and display the books returned by the server -
Add a
createBook
function with annotations matching the API -
Call
createBook
to post a new book to the server and then display the list of books (including the freshly created one)
Finally:
- Add some Toasts to properly display and handle network errors
- Start Android Studio
- Select
Open an existing Android Studio project
and pick this directory
That's it! You can code!