Android 10 min read • Updated Aug 2026

Building a High-Performance Android Wallpaper App with Kotlin & Retrofit

Learn how to consume NexWall Wallpaper REST API in Android Native with Kotlin, Coroutines, Flow, Retrofit2, and Glide with offline caching.

⚠️ Production Security Warning — Read Before Publishing to App Store

The code samples in this guide use a Bearer token directly in client-side mobile code. This is for local development and prototyping only. Any API key or Bearer token embedded inside a compiled Android APK or iOS IPA can be extracted in under 60 seconds using free tools like jadx-gui or apktool.

For production apps on Google Play / App Store, always use a backend proxy architecture:

Your Mobile App → Your Own Secure Backend → NexWall API

Your backend holds the NexWall Bearer token securely. It proxies requests from your app, adds auth, and returns responses — keeping your API key permanently hidden from reverse engineers. Read API Docs →

1. Setting Up Retrofit in Android Studio

Add the following dependencies in your app-level build.gradle.kts:

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("io.coil-kt:coil:2.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")

2. Kotlin Retrofit API Service

interface NexWallApiService {
    @GET("api/developer/v1/wallpapers")
    suspend fun getWallpapers(
        @Header("Authorization") token: String = "Bearer YOUR_API_KEY",
        @Header("Accept") accept: String = "application/json",
        @Query("page") page: Int = 1,
        @Query("per_page") perPage: Int = 30,
        @Query("category_id") categoryId: Int? = null
    ): Response<WallpaperResponse>
}

3. Jetpack Compose or XML Image Loading

Load the 4K wallpaper smoothly using Coil in Jetpack Compose:

AsyncImage(
    model = wallpaper.thumbnailUrl,
    contentDescription = "4K Wallpaper",
    contentScale = ContentScale.Crop,
    modifier = Modifier
        .fillMaxWidth()
        .aspectRatio(9f / 16f)
        .clip(RoundedCornerShape(14.dp))
)

Want to test this endpoint right now?

Use the interactive Live Sandbox Console to test queries without writing code.

Try In Sandbox