Creation Steps to Create a API connected Android app.
- Create a new AS project, with an Empty activity
- ADD GRADLE.PROPERTIES TO .GITIGNORE: Make sure this file is in your .gitignore file before adding files.
- Create a github repo and connect to the project.
- Push to the repo
- Add latest OkHttp to dependencies
compile 'com.squareup.okhttp3:okhttp:3.9.0' - Add Internet permissions to the AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/> - Download Postman and test your API's to call
- Create adapters, models, services and ui packages. Move MainActivity to the ui package.
- ADD SECRETS TO GRADLE.PROPERTIES: Put your API key values in the file gradle.properties looking like this
StevesLastName = "Zaske"
You might want to email yourself a copy of the gradle.properties file, so you can reproduce the app. 10. EDIT BUILD.GRADLE FILE: Then add a line in your build.gradle file (Module:app) that looks like this
android {
buildTypes.each {
it.buildConfigField 'String', 'STEVES_LAST_NAME', StevesLastName
```
This tells gradle to auto generate these Static Strings in the ***BuildConfig.java*** file.
11. CREATE A CONSTANTS.JAVA CLASS. Create a new class called Constants.java and add a line like:
`public static final String STEVES_LAST_NAME = BuildConfig.STEVES_LAST_NAME;`
Now you can access your strings in your code using this format = `Constants.STEVE_LAST_NAME`
12. Add instructions to your README.md file to explain to others how to re-create your gradle.properties
13. Add a DataService. Use myRestaurants as an example.
14. Add a TAG to the MainActivity `public static final String TAG = MainActivity.class.getSimpleName();`
15. Add ButterKnife to build.gradle `compile 'com.jakewharton:butterknife:8.8.1'` and `annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'`
16. Add a button to the Activity layout (use BK), add an onClick listener.
17. Create a object class for the object we're pulling from the API
18. Instantiate the new service, and make the API call. Pipe results to the LogCat.
19. If successful, commit and push to github.
## INSTRUCTION ON HOW TO GET API ACCESS
1. First you need to get an API key
2. Then add a line to your gradle.properties file that looks like this `themoviedb_api_key="YOUR_API_KEY_HERE"` *be sure to include the quote marks*