Weather forecasting app, as the name suggests, a simple weather app which will display current weather and forecast to the end user. Not only current weather, but users will also be able to get hourly, daily and many other forecasts based on their geolocation coordinates. This is a really easy tutorial which uses Google Maps API key to fetch data.
It can be used for fetching real time weather forecasting for any location which can help you or your business to solve various problems related to weather. You can integrate and use this method to use the fetched data in any of your app made with Android studio. Moreover you can also get a similar working Weather forecasting app for iOS devices.
In this tutorial you’ll learn:
- Integration of Weather data services.
- How to use IBM cloud services.
- How to use geographical info by user to get weather data with Google Maps API.
Before you begin
Make sure you have all the development tools installed on your rig, also get a Google Map API key, you can check the prerequisites below and go further.
- Make sure you have the updated Android Studio and Gradle on your device.
- Get Google Maps API Key.
- Create Weather Data instance.
Download or update Android studio and gradle, also get the API keys from Google Maps before you begin.
Steps to create Weather forecasting App
- Install all the required development tools, mentioned above and create a new project in Android studio. Make sure you have the latest gradle installed to avoid unwanted compilation errors.
- Once the gradle sync is over, Find your Google Maps API key and copy it.
- Now go to res/values/google_maps_api.xml
- Once you open that file, enter your API key there.
<string name=”google_maps_key” templateMergeStrategy=”preserve” translatable=”false”>YOUR_KEY_HERE</string>
Replace YOUR_KEY_HERE with the key you got from Google Maps API.
- If you have already created a Weather service instance then open res/values/weather_credentials.xml and enter your credentials in the following manner.
Replace YOUR_USERNAME_HERE, YOUR_PASSWORD_HERE and YOUR_HOST_HERE with the credentials you got with IBM Weather Company Data instance.
Tip – If you get & (and character) in your credentials don’t forget to escape it as &
Now sync the gradle again, build APK and run it on Emulator or on your device.
Kudos! That was all to create a weather forecasting app using IBM weather data and Google Maps API.
Now you can move that pointer anywhere and long press on it to get a popup which will show you the weather forecast for that location. You can use this in your business app to solve problems which are related to weather in realtime.
Feel Free to share your thoughts in the comment section below.
Don't forget to follow us on Twitter, like our Facebook Fan Page and Add us to your circles on Google+ to keep you updated with the latest technology news, gadget reviews, launches around the world and much more