Building a High-Performance Android Wallpaper App with Kotlin & Retrofit
Learn how to consume the NexWall wallpaper REST API in native Android with Kotlin, Coroutines, Retrofit and Coil, render a 9:16 Jetpack Compose grid, and start from a runnable open-source starter app.
What does this Android Kotlin guide cover?
How to call the NexWall wallpaper REST API from a native Android app in Kotlin: a Retrofit suspend function for GET /wallpapers (page, per_page, category_id), Coil to load thumbnails into a 9:16 Jetpack Compose grid, and a Bearer API key. The Free plan gives 100 requests/day with no credit card, and the open-source starter app runs with your key.
Runnable starter: github.com/kodnextechnologies/nexwall-android-kotlin-wallpaper-app (open source, MIT licence). Clone it, add your free API key and run it.
⚠️ 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 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 →
This guide connects a native Kotlin app to the NexWall wallpaper API: Retrofit fetches pages of wallpapers as JSON, Coil loads the WebP thumbnails, and Jetpack Compose shows them in a 9:16 grid. Add the INTERNET permission to your manifest and keep your API key out of source control.
1. Setting Up Retrofit in Android Studio
Add the following dependencies in your app-level build.gradle.kts (coil-compose provides AsyncImage):
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("io.coil-kt:coil-compose:2.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
2. Kotlin Retrofit API Service
The /wallpapers endpoint returns a data array plus current_page and last_page for pagination. Map only the fields you use:
data class WallpaperResponse(
val data: List<Wallpaper>,
@SerializedName("current_page") val currentPage: Int,
@SerializedName("last_page") val lastPage: Int
)
data class Wallpaper(
val id: Int,
@SerializedName("image_url") val imageUrl: String,
@SerializedName("thumbnail_url") val thumbnailUrl: String,
val width: Int?,
val height: Int?
)
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>
}
val api: NexWallApiService = Retrofit.Builder()
.baseUrl("https://nexwall.kodnextech.com/")
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(NexWallApiService::class.java)
3. Jetpack Compose or XML Image Loading
Load the wallpaper thumbnail smoothly using Coil in Jetpack Compose:
AsyncImage(
model = wallpaper.thumbnailUrl,
contentDescription = "Wallpaper preview",
contentScale = ContentScale.Crop,
modifier = Modifier
.fillMaxWidth()
.aspectRatio(9f / 16f)
.clip(RoundedCornerShape(14.dp))
)
Use thumbnail_url in the grid and load the full-size image_url only on the detail screen; full images are portrait HD up to 4K, most around 1440×2560.
4. Next Steps: Apply the Wallpaper
When the user taps Apply, use WallpaperManager to set wallpaper programmatically on the home screen, lock screen or both. To rotate wallpapers in the background, see the auto wallpaper changer with WorkManager; for looping MP4 backgrounds, the live wallpaper tutorial covers WallpaperService. Shipping on iOS too? The Flutter tutorial builds the same app for both platforms.
Want to test this endpoint right now?
Use the interactive Live Sandbox Console to test queries without writing code.