Documentation for WeatherSDK with the correct installation instructions for importing it as a project module:
WeatherSDK is a simple and powerful Android library designed to fetch weather data seamlessly from Weatherbit. It provides developers with an easy-to-integrate solution for retrieving weather information in Android applications.
- Easy Integration: Quickly integrate the library into any Android project.
- Real-Time Weather Data: Fetches current weather conditions and forecasts.
- Customizable: Offers options to customize the data retrieval and display.
- Lightweight: Minimal impact on the app’s performance.
- Download or clone the WeatherSDK project.
- Open your Android project in Android Studio.
- Go to
File > New > Import Module
. - Select the WeatherSDK directory and click
Finish
. - Open your app's
build.gradle
file and add the following line to thedependencies
block:
implementation project(':weather-sdk')
Here's a simple guide to get you started with WeatherSDK.
Before using the library, initialize it in your Application
class or Activity
:
import com.android.weather.sdk.WeatherSDK
import com.android.weather.sdk.WeatherSDKImpl
val weatherSDK = WeatherSDKImpl().apply {
initialize("YOUR_API_KEY")
setWeatherSDKListener(this@YourActivity)
}
Ensure that you have the necessary permissions in your AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" />
Use the library to fetch weather data by following the usage instructions below.
You can fetch weather data by city name and display it in a fragment:
import com.android.weather.sdk.WeatherSDK
import com.android.weather.sdk.WeatherSDKImpl
import androidx.fragment.app
val weatherSDK = WeatherSDKImpl().apply {
initialize("YOUR_API_KEY")
setWeatherSDKListener(this@YourActivity)
}
val cityName = "Berlin"
val weatherFragment = weatherSDK.launch(cityName)
if (savedInstanceState == null) {
// Add the fragment to the container
supportFragmentManager.commit {
setReorderingAllowed(true)
replace(R.id.fragmentContainerView, weatherFragment)
}
}
WeatherSDK supports several configuration options:
Ensure you have your API key ready for initialization. Replace "YOUR_API_KEY"
with your actual API key from weatherbit when initializing WeatherSDK:
val weatherSDK = WeatherSDKImpl().apply {
initialize("YOUR_API_KEY")
}
For complete documentation, please refer to the WeatherSDK Documentation.
This documentation provides detailed instructions and examples for integrating and using WeatherSDK in your Android applications.
This project is licensed under the MIT License - see the LICENSE file for details.
For any inquiries or support, please contact me at [email protected].
This version correctly describes how to import WeatherSDK as a project module and ensures consistency throughout the documentation.