Before we get started building our web application, we need to complete a few set up steps.
Once you have made your account, you will notice you already have an application with API keys. You will need these keys to complete this tutorial.
redirect_urifor your application. We will be using this in the next section. For Android, we require the custom URI scheme to be in the format of
“sc” + clientId + “://” + hostname. For now, you can just set it to
“sc” + clientId + “://exchange”. For more information about redirect URI's with custom URI scheme, refer to our docs.
Make sure you have cloned this repo and installed the required dependencies -
git clone https://github.com/smartcar/getting-started-android-sdk.git cd getting-started-android-sdk/tutorial
Build the project by opening Android Studio and clicking Build.
Set the following constants -
// app/src/main/res/values/strings.xml <string name="client_id">[yourClientId]</string>
We will be setting up a server for later, for our Android application to communicate with. For now, let's assume our server is listening on
http://10.0.2.2:8000 and store it as a constant. We do not set the
app_server to the
localhost because the Android emulator runs in a VM, therefore
localhost will be the emulator's own loopback address.
// app/src/main/res/values/strings.xml <string name="app_server">http://10.0.2.2:8000</string>
Now that we've set up our application, let's learn more about Smartcar's authorization flow.