Weather app for Android
Current weather and forecast from your phone's location, using Retrofit and the free Open-Meteo API.
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
Dependencies
Retrofit, a JSON converter (kotlinx.serialization or Moshi), and play-services-location.
- 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
Permission
Request ACCESS_COARSE_LOCATION with rememberLauncherForActivityResult; explain why if denied.
- 4
Location
FusedLocationProviderClient.lastLocation (fall back to a city search if null).
- 5
UI state
sealed interface UiState { Loading; Success(data); Error(msg) } in the ViewModel; the screen shows each case.
- 6
City search
Call Open-Meteo's geocoding endpoint and let the user pick a result.
- 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