Build Your Own Weather App for Wear OS Using OpenWeather API
Building a weather app for Wear OS smartwatches teaches you about API integration, JSON parsing, battery-optimized updates, and designing for tiny screens. Here's how to create a functional weather app using OpenWeather API.
What We're Building
- Current temperature display with weather icons
- Location-based weather using device GPS
- Hourly auto-updates in background
- Power-optimized to preserve battery
- Offline caching for last known weather
Prerequisites
- Wear OS device or emulator
- Android Studio (latest version)
- OpenWeather API key (free at openweathermap.org)
- Basic Kotlin/Java knowledge
Step 1: Get OpenWeather API Key
- Sign up at openweathermap.org
- Navigate to API keys section
- Generate new key (free tier: 60 calls/minute, 1M calls/month)
- Wait 10-15 minutes for activation
Step 2: Create Wear OS Project
In Android Studio:
- New Project → Wear OS templates
- Select "Blank Wear OS app"
- Language: Kotlin, Minimum SDK: API 30
Step 3: Add Dependencies
In build.gradle (Module: app):
dependencies {
// Retrofit for API calls
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
// Coroutines for async operations
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
// Location services
implementation 'com.google.android.gms:play-services-location:21.0.1'
// Wear OS libraries
implementation 'androidx.wear:wear:1.3.0'
}
Step 4: Add Permissions
In AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Step 5: Create API Service
WeatherApiService.kt:
interface WeatherApiService {
@GET("weather")
suspend fun getWeather(
@Query("lat") latitude: Double,
@Query("lon") longitude: Double,
@Query("appid") apiKey: String,
@Query("units") units: String = "metric"
): WeatherResponse
}
Step 6: Data Models
Parse JSON from OpenWeather:
data class WeatherResponse(
val main: Main,
val weather: List,
val name: String
)
data class Main(
val temp: Double,
val feels_like: Double,
val humidity: Int
)
data class Weather(
val id: Int,
val main: String,
val description: String,
val icon: String
)
Step 7: Design UI for Wear OS
Key considerations for watch screens:
- Large text – Easy to read at glance
- Minimal elements – Don't clutter tiny screen
- Round-aware layouts – Works on circular and square watches
- High contrast – Readable in sunlight
activity_main.xml:
<androidx.wear.widget.BoxInsetLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/temperatureText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="48sp"
android:text="--°" />
<ImageView
android:id="@+id/weatherIcon"
android:layout_width="64dp"
android:layout_height="64dp" />
</androidx.wear.widget.BoxInsetLayout>
Step 8: Implement Location & API Call
MainActivity.kt:
class MainActivity : WearableActivity() {
private val API_KEY = "your_api_key_here"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
getLocationAndWeather()
}
private fun getLocationAndWeather() {
// Get location using FusedLocationProviderClient
// Call API with coordinates
// Update UI with weather data
}
}
Step 9: Power Optimization
Batch Updates
Don't update every minute—hourly is sufficient for weather.
Use WorkManager
Schedule periodic background updates:
val weatherWorkRequest = PeriodicWorkRequestBuilder<WeatherWorker>(
1, TimeUnit.HOURS
).build()
WorkManager.getInstance(context).enqueue(weatherWorkRequest)
Cache Last Result
Store weather data locally (SharedPreferences) to show immediately on app launch without API call.
Step 10: Weather Icons
Map OpenWeather icon codes to local drawable resources:
fun getWeatherIcon(iconCode: String): Int {
return when(iconCode) {
"01d" -> R.drawable.ic_clear_day
"01n" -> R.drawable.ic_clear_night
"02d", "02n" -> R.drawable.ic_few_clouds
"09d", "09n" -> R.drawable.ic_rain
"10d", "10n" -> R.drawable.ic_rain_day
"11d", "11n" -> R.drawable.ic_thunderstorm
"13d", "13n" -> R.drawable.ic_snow
else -> R.drawable.ic_unknown
}
}
Advanced Features
Complications
Show weather on watch face as complication:
- Create ComplicationProviderService
- Provide weather data to watch faces
- Update periodically
Tiles
Wear OS Tiles for quick glance:
- Swipeable tile showing current weather
- Multiple cities support
- Forecast for next hours
Multi-City
- Save favorite cities
- Swipe between locations
- Persistent storage with Room database
Testing
On Emulator
- Create Wear OS emulator in AVD Manager
- Set location manually in emulator
- Test different weather conditions
On Real Device
- Enable Developer Options on watch
- Enable ADB debugging
- Connect via Wi-Fi or Bluetooth
- Deploy and test in real conditions
Common Issues & Solutions
API Key Not Working
Wait 10-15 minutes after generation. Check activation email.
Location Permission Denied
Request runtime permissions properly on Android 6+.
Battery Drain
Reduce update frequency. Use WorkManager instead of AlarmManager. Avoid wake locks.
UI Not Fitting Round Screens
Use BoxInsetLayout for round-aware positioning.
Publishing to Play Store
- Create signed APK/Bundle
- Prepare screenshots from both round and square watches
- Write description highlighting Wear OS features
- Set up Google Play Developer account
- Upload and publish
Learning Outcomes
- API integration: RESTful APIs, Retrofit, async calls
- JSON parsing: Data classes, Gson converter
- Location services: Fused Location Provider
- Wear OS specifics: Complications, Tiles, round screens
- Battery optimization: Background work scheduling
- Permissions: Runtime permission handling
Conclusion
Building a Wear OS weather app combines API integration, mobile development, and wearable-specific design considerations. The OpenWeather API provides reliable data, Retrofit simplifies networking, and Wear OS libraries handle device-specific challenges.
From displaying temperature on your wrist to sophisticated complications and tiles, this project teaches fundamental skills applicable to any wearable or mobile app development.
Start building, deploy to your smartwatch, and enjoy checking weather at a glance from your wrist.