0Pricing
Kotlin Academy · Lesson

Platform APIs

Access native features.

Accessing Native Features

Shared code sometimes needs device features — storage, settings, the clock, networking engine. KMM offers several ways to reach native APIs cleanly.

expect/actual for Primitives

For small platform values, use expect/actual. Common code stays clean while each platform fills in the detail.

// commonMain
expect fun currentTimeMillis(): Long

// androidMain
actual fun currentTimeMillis(): Long = System.currentTimeMillis()

All lessons in this course

  1. KMM Project Structure
  2. expect and actual
  3. Sharing Business Logic
  4. Platform APIs
← Back to Kotlin Academy