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

Prerequisites

Step 1: Get OpenWeather API Key

  1. Sign up at openweathermap.org
  2. Navigate to API keys section
  3. Generate new key (free tier: 60 calls/minute, 1M calls/month)
  4. Wait 10-15 minutes for activation

Step 2: Create Wear OS Project

In Android Studio:

  1. New Project → Wear OS templates
  2. Select "Blank Wear OS app"
  3. 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:

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:

Tiles

Wear OS Tiles for quick glance:

Multi-City

Testing

On Emulator

  1. Create Wear OS emulator in AVD Manager
  2. Set location manually in emulator
  3. Test different weather conditions

On Real Device

  1. Enable Developer Options on watch
  2. Enable ADB debugging
  3. Connect via Wi-Fi or Bluetooth
  4. 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

  1. Create signed APK/Bundle
  2. Prepare screenshots from both round and square watches
  3. Write description highlighting Wear OS features
  4. Set up Google Play Developer account
  5. Upload and publish

Learning Outcomes

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.