Pricing

Docs

Android

Setup

Before we get started building our web application, we need to complete a few set up steps.


1. Sign up for a Smartcar account

Go to our developer dashboard to sign up with Smartcar.

2. Retrieve your API keys

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.

3. Configure your application

You will need to set a redirect_uri for 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.

4. Initialize your application

Note: Please ensure that you have Android Studio installed and configured with a virtual device. You can refer to Android Studio's official guide in order to do so.

Please make sure that you have cloned the Getting Started repo -

  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $
git clone https://github.com/smartcar/getting-started-android-sdk.git

Note: Do not "checkout from version control" with the Getting Started repo in Android Studio, as it will not open the proper module in Android Studio.

Open getting-started-android-sdk/tutorial in Android Studio as an existing project and build from existing sources. Android Studio should automatically import the required dependencies and build gradle.

Set the following constants in the project -

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
// app/src/main/res/values/strings.xml

<string name="smartcar_auth_scheme">sc[yourClientId]</string>
<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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
// app/src/main/res/values/strings.xml

<string name="app_server">http://10.0.2.2:8000</string>
Note: If you want to run the Android app without writing any code, follow along with the Readme.

Now that we've set up our application, let's learn more about Smartcar Connect.