Skip to content

Setup

Import into your project

This library uses JitPack.io so you’ve to add the repo to your projects gradle file:

repositories {
    maven { url "https://jitpack.io" }
}

Then, on app level add the library:

dependencies {
    // Commit hash from 2021-05-05
    def tmdb_version = 'c3069368648f2677004acf21a17e94015ceaf6d7'
    def threetenabp_version = '1.3.1'

    implementation "com.github.vkay94:TMDb-Kotlin:$tmdb_version"
    implementation "com.jakewharton.threetenabp:threetenabp:$threetenabp_version"
}

This module uses the ThreetenABP library to ensure LocalDate support in Android versions below API 26 so you should use this as well for using dates.

Initialize the instance

Basic initialization:

TMDb.init(API_KEY [, V4_AUTH_KEY]) // [] = optional

In Android applications it is best-practice to initialize the instance directly within App to make use of Kotlin’s objects, so the instance can be used in the whole app directly.

class App : Application() {

    override fun onCreate() {
        TMDb.init(API_KEY)
        // or TMDb.init(YOUR_API_KEY, V4_AUTH_KEY) for authentication
    }
}
    <manifest
        ...> 
        <uses-permission android:name="android.permission.INTERNET" />

        <application
            android:name=".App"
            ...>
        </application>
    </manifest>