🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

Weather app for Android

Current weather and forecast from your phone's location, using Retrofit and the free Open-Meteo API.

Intermediate⏱ 10–14 hoursđŸĒœ 7 stepsKotlinRetrofitComposeOpen-Meteo

What you'll learn

  • ◆Networking with Retrofit and coroutines
  • ◆Runtime location permission
  • ◆Loading, success and error UI states

What you'll build

  • ✓Uses your location (with permission)
  • ✓Current conditions and 7-day forecast
  • ✓Search other cities
  • ✓Pull to refresh

Step-by-step guide

  1. 1

    Dependencies

    Retrofit, a JSON converter (kotlinx.serialization or Moshi), and play-services-location.

  2. 2

    API interface

    interface WeatherApi { @GET("v1/forecast") suspend fun forecast(@Query("latitude") lat: Double, @Query("longitude") lon: Double, @Query("current") current: String, @Query("daily") daily: String, @Query("timezone") tz: String = "auto"): ForecastDto }

  3. 3

    Permission

    Request ACCESS_COARSE_LOCATION with rememberLauncherForActivityResult; explain why if denied.

  4. 4

    Location

    FusedLocationProviderClient.lastLocation (fall back to a city search if null).

  5. 5

    UI state

    sealed interface UiState { Loading; Success(data); Error(msg) } in the ViewModel; the screen shows each case.

  6. 6

    City search

    Call Open-Meteo's geocoding endpoint and let the user pick a result.

  7. 7

    Refresh and cache

    Pull to refresh; keep the last result in DataStore so the app opens instantly.

🚀 Make it stand out

  • +Hourly chart
  • +Severe weather notifications
  • +Wear OS tile