B4A Library ICOSWorldForecast 3.50

View attachment 14755 View attachment 14754 View attachment 16846 Hi guys, ICOSWorldForecast is here.


It's a pleasure to introduce the new library of weather forecast.

The zip include:

The library, and the demo

INSTALLATION:

Copy the Library in your Basic For Android Library.

Copy the folder weathericon is located in files in the demo. In your one.


RENAME:
ICOSWorldForecast2.71.part1.zip and ICOSWorldForecast2.71.part2.zip

TO:
ICOSWorldForecast2.71.part1.rar and ICOSWorldForecast2.71.part1.rar

In this version I add WeatherUrl and 2 more days forecast.

You can use your own icons, instead of my icons.

For this new version 2.71 you need the new key.

You must register to obtain the new key, otherwise you will get error.

Use the address below to register.

World Weather Online - Welcome to the World Weather Online Developer Network!

don't forget to replace the ApiKey="XXXXXXXXXXXXXX" with your private key

This demos, I made with my galaxy tab 7 600x1024

any question or bugs please report to me.

big Thx to warwound for is fantastic auto-generated reference.


ICOSWorldForecast
Author:
Giuseppe Salvi
Version: 2.81
  • ICOSWorldForecast
    Methods:
    • FCDate (index As Int) As String
      Return Date for which the weather is forecasted
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCDate(0)
    • FCIcon (index As Int) As Bitmap
      Return Weather symbol image
      example:
      Dim a As ICOSWorldForecast
      Image1.SetBackgroundImage=a.FCWeatherIcon(0)
    • FCIconUrl (index As Int) As String
      Return URLIcon For Forecast Condition
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCIconUrl(0)
    • FCPrecipitationMM (index As Int) As String
      Return Precipitation amount in millimeter
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCPrecipitationMM(0)
    • FCTempMaxCelsius (index As Int) As String
      Return Day and night max temperature in Celcius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMaxCelsius(0)
    • FCTempMaxFahrenheit (index As Int) As String
      Return Day and night max temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMaxFahrenheit(0)
    • FCTempMinCelsius (index As Int) As String
      Return Day and night min temperature in Celcius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMinCelsius(0)
    • FCTempMinFahrenheit (index As Int) As String
      Return Day and night max temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMinFahrenheit(0)
    • FCWeatherCode (index As Int) As String
      Return Weather Code
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWeatherCode(0)
    • FCWeatherDesc (index As Int) As String
      Return Weather description
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWeatherDesc(0)
    • FCWinddir16Point (index As Int) As String
      Return 16-Point compass wind direction
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddir16Point(0)
    • FCWinddirDegree (index As Int) As String
      Return Wind direction in degree
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddirDegree(0)
    • FCWinddirection (index As Int) As String
      Return Compass Wind direction
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddirection(0)
    • FCWindspeedKmph (index As Int) As String
      Return Wind speed in kilometer per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWindspeedKmph(0)
    • FCWindspeedMiles (index As Int) As String
      Return Wind speed in Miles per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWindspeedMiles(0)
    • FindLatAndLong As String
      Retrieve accurate latitude and longitude from GPS or network services
    • FindLocation As String
      Retrieve accurate location from GPS or network services
    • Full7DayName (day As Int) As String
      Return Full name of the day ( Monday )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Full7DayName(0) ' 0 = today - 1 = tomorrow etc etc
    • GetList (mCity As String) As ArrayList
      Set the City Name you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      Dim l As List
      Dim lv1 As ListView
      l = a.GetList("Los Angeles")
      For n = 0 To l.Size-1
      lv1.AddSingleLine(l.Get(n))
      Next
      Sub lv1_ItemClick (Position As Int, Value As Object)ics.CityName = lv1.GetItem(Position)
      lv1.Clear
      End Sub
    • Initialize (EventName As String)
      Initilize the object
    • Short7DayName (day As Int) As String
      Return Short name of the day ( Mon )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Short7DayName(0) ' 0 = today - 1 = tomorrow etc etc
    • StringFormat (format As String, object As Object, object1 As Object) As String
      Return Formatted String
      example:
      Label1.Text=StringFormat("Lat: %1$s - Long: %2$s ",Latitude,Longitude)
    • isWiFiConnected As Boolean
      Check if WiFi is Connected
    Permissions:
    • android.permission.ACCESS_ASSISTED_GPS
    • android.permission.ACCESS_COARSE_LOCATION
    • android.permission.ACCESS_FINE_LOCATION
    • android.permission.ACCESS_GPS
    • android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.ACCESS_WIFI_STATE
    • android.permission.CONTROL_LOCATION_UPDATES
    • android.permission.INTERNET
    Properties:
    • ApiKey As String [write only]
      Set your personal ApiKey
      example:
      Dim a As ICOSWorldForecast
      a.ApiKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    • AreaName As String [read only]
      Return Name of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.AreaName
    • CCCloudCover As String [read only]
      Return Cloud Cover in %
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCCloudCover
    • CCHumidity As String [read only]
      Return Humidity in %
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCHumidity
    • CCIcon As Bitmap [read only]
      Return Weather symbol image
      example:
      Dim a As ICOSWorldForecast
      Image1.SetBackgroundImage=a.CCWeatherIcon
    • CCIconUrl As String [read only]
      Return URLIcon For Current Condition
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCIconUrl
    • CCLocalObsDateTime As String [read only]
      Return Local Observation date and time
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCLocalObsDateTime
    • CCObservationTime As String [read only]
      Return Observation time (UTC)
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCObservationTime
    • CCPrecipitationMM As String [read only]
      Return Precipitation Amount in Millimeter
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.PrecipitationMM
    • CCPressure As String [read only]
      Return Atmospheric pressure in Milibars
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCPressure
    • CCTempCelsius As String [read only]
      Return Temperature in Celsius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCTempCelsius
    • CCTempFahrenheit As String [read only]
      Return Temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCTempFahrenheit
    • CCVisibility As String [read only]
      Return Visibility kilometers per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCVisibility
    • CCWeatherCode As String [read only]
      Return Weather Code
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWeatherCode
    • CCWeatherDescription As String [read only]
      Return Weather Description
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWeatherDescription
    • CCWinddir16Point As String [read only]
      Return 16-Point wind direction compass
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWinddir16Point
    • CCWinddirDegree As String [read only]
      Return Wind direction in degree
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWinddirDegree
    • CCWindspeedKmph As String [read only]
      Return Wind speed in kilometer per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWindspeedKmph
    • CCWindspeedMiles As String [read only]
      Return Wind speed in Miles per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWindspeedMiles
    • CityName As String [write only]
      Set City you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      a.CityName="New York"
    • Country As String [read only]
      Return Name of the Country
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Country
    • CurrentDate As String [read only]
      Return Current Day,Month,Year ( Friday, 28 September, 2012 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CurrentDate
    • CurrentTime As String [read only]
      Return Current time ( 02.09 PM )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CurrentTime
    • DstOffset As String [read only]
      Return DstOffset = ( GMT +2 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.DstOffset
    • GmtOffset As String [read only]
      Return GmtOffset = ( GMT +1 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.GmtOffset
    • LatAndLong As String [write only]
      Set Lat and Long you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      a.LatAndLong="40.714,-74.006"
    • Latitude As Object [read only]
      Return Latitude of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Latitude
    • Longitude As Object [read only]
      Return Longitude of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Longitude
    • Population As String [read only]
      Return Population of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Population
    • Region As String [read only]
      Return Name of the Region
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Region
    • Sunrise As String [read only]
      Return Sunrise = 06:04
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Sunrise
    • Sunset As String [read only]
      Return Sunset = 19:36
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Sunset
    • TimeZoneID As String [read only]
      Return TimeZoneID = Europe/Rome
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.TimeZoneID
    • Version As Double [read only]
      Return the version of this library
    • WeatherUrl As String [read only]
      Return url of the city [ http://www.worldweatheronline.com/London-weather/City-of-London-Greater-London/GB.aspx ]
      example:
      Dim Webview1 As Webview
      Webview1.LoadUrl(a.WeatherUrl)
 

Attachments

  • ICOSWorldForecast_DEMO.part1.zip
    293 KB · Views: 891
  • ICOSWorldForecast_DEMO.part2.zip
    167.1 KB · Views: 703
  • Main.png
    Main.png
    86.8 KB · Views: 854
  • Widget.jpg
    Widget.jpg
    81.8 KB · Views: 842
  • ICOSWorldForecast.png
    ICOSWorldForecast.png
    156.3 KB · Views: 907
  • ICOSWorldForecastFree_v3.50_lib_fix.zip
    53.9 KB · Views: 451
Last edited:

grant1842

Active Member
Licensed User
Longtime User
I have the same problem with the emulator I put it on a 2.2 phone and it worked well

Sent from my SCH-S720C using Tapatalk 2
 

walterf25

Expert
Licensed User
Longtime User
Work Around for 5 day forecast

Hi All, for those interested i wrote this little sub to fix an issue when getting the 5 day forecast with this library, i'm not sure if there's anything i did wrong but i could not seem to find a way to do this with the library so i decided to do it this way.

Basically when you use this code like this

B4X:
   l1.Text=a.Full5DayName(0)&CRLF&a.FCDate(0)
   l3.Text=a.Full5DayName(1)&CRLF&a.FCDate(1)
   l5.Text=a.Full5DayName(2)&CRLF&a.FCDate(2)
   l7.Text=a.Full5DayName(3)&CRLF&a.FCDate(3)
   l9.Text=a.Full5DayName(4)&CRLF&a.FCDate(4)
the name of the day doesn't match the Date, check the image below!
weatherscreenshot.jpg

I needed a way for the days to match the dates so here it is, if anyone has a more efficient and cleaner way to fix this i'd like to hear from you!

here is how i fixed this issue!

B4X:
Sub GenerateDays
Dim day11 As Int
Dim daycount As Int 
Dim dayslist As List 
Dim today As Long
dayslist.Initialize
dayslist.AddAll(Array As String("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"))
today = DateTime.Now
day11 = DateTime.GetDayOfWeek(today)
daycount = day11 - 1
For i = 0 To 3
day.Add(dayslist.Get(daycount))
daycount = daycount + 1
If daycount = 7 Then
daycount = 0
day.Add(dayslist.Get(daycount))
daycount = daycount + 1
End If
Next
Return day
End Sub

and here is how i call the sub and fill in the 5 day forecast!

B4X:
Dim Nextdays as list
GenerateDays
nextdays.Initialize 
nextdays.AddAll(Array As String(day.Get(0), day.Get(1), day.Get(2), day.Get(3), day.Get(4)))


day1.text = nextdays.Get(0)&CRLF&ics.FCDate(0)
day2.text = nextdays.Get(1)&CRLF&ics.FCDate(1)
day3.text = nextdays.Get(2)&CRLF&ics.FCDate(2)
day4.text = nextdays.Get(3)&CRLF&ics.FCDate(3)
day5.text = nextdays.Get(4)&CRLF&ics.FCDate(4)

and here's a screenshot of how it should look!
weatherscreenshot2.jpg

Hope this helps someone :D

Cheers,
Walter
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi All, for those interested i wrote this little sub to fix an issue when getting the 5 day forecast with this library, i'm not sure if there's anything i did wrong but i could not seem to find a way to do this with the library so i decided to do it this way.

Basically when you use this code like this

B4X:
   l1.Text=a.Full5DayName(0)&CRLF&a.FCDate(0)
   l3.Text=a.Full5DayName(1)&CRLF&a.FCDate(1)
   l5.Text=a.Full5DayName(2)&CRLF&a.FCDate(2)
   l7.Text=a.Full5DayName(3)&CRLF&a.FCDate(3)
   l9.Text=a.Full5DayName(4)&CRLF&a.FCDate(4)
the name of the day doesn't match the Date, check the image below!
View attachment 14927

I needed a way for the days to match the dates so here it is, if anyone has a more efficient and cleaner way to fix this i'd like to hear from you!

here is how i fixed this issue!

B4X:
Sub GenerateDays
Dim day11 As Int
Dim daycount As Int 
Dim dayslist As List 
Dim today As Long
dayslist.Initialize
dayslist.AddAll(Array As String("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"))
today = DateTime.Now
day11 = DateTime.GetDayOfWeek(today)
daycount = day11 - 1
For i = 0 To 3
day.Add(dayslist.Get(daycount))
daycount = daycount + 1
If daycount = 7 Then
daycount = 0
day.Add(dayslist.Get(daycount))
daycount = daycount + 1
End If
Next
Return day
End Sub

and here is how i call the sub and fill in the 5 day forecast!

B4X:
Dim Nextdays as list
GenerateDays
nextdays.Initialize 
nextdays.AddAll(Array As String(day.Get(0), day.Get(1), day.Get(2), day.Get(3), day.Get(4)))


day1.text = nextdays.Get(0)&CRLF&ics.FCDate(0)
day2.text = nextdays.Get(1)&CRLF&ics.FCDate(1)
day3.text = nextdays.Get(2)&CRLF&ics.FCDate(2)
day4.text = nextdays.Get(3)&CRLF&ics.FCDate(3)
day5.text = nextdays.Get(4)&CRLF&ics.FCDate(4)

and here's a screenshot of how it should look!
View attachment 14928

Hope this helps someone :D

Cheers,
Walter
Hi walter, Why would you create a routine when already is there Short5DayName?

Use Short5DayName instead Full5DayName that is all.

best regard

G.Salvi
 

walterf25

Expert
Licensed User
Longtime User
five day forecast

Hi Lonelystar, the routine i created is not to get the shortnames for the days, it is simply to make the days match with the dates, look at both images and you will see what i mean!

Cheers,
Walter
 

Paulsche

Well-Known Member
Licensed User
Longtime User
Problem under Android 2.2

I have now bought a used Smartphone Dellwith Android 2.2.2 for testing.
On the hardware with Android 2.2.2 , the library is not run, even the demos not run.

The APP is force closed.

when i take out wetter.Initialize("wetter")
the APP runs korrekt.

It may be that the problem is on my local PC? Java installation?


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


Exception!!! threadid=1: thread exiting with uncaught exception (group=0x4001d858)


main_activity_create (java line: 241)
java.lang.NoClassDefFoundError: android.os.StrictMode$ThreadPolicy$Builder


at com.giuseppe.salvi.icos.library.weather.ICOSWorldForecastWrapper.Initialize(ICOSWorldForecastWrapper.java:77)
at giuseppe.salvi.icosworldforecast2.main._activity_create(main.java:241)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at giuseppe.salvi.icosworldforecast2.main.afterFirstLayout(main.java:84)
at giuseppe.salvi.icosworldforecast2.main.access$100(main.java:16)
at giuseppe.salvi.icosworldforecast2.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
 
Last edited:

Paulsche

Well-Known Member
Licensed User
Longtime User
Android 2.2 Test

I have now found on my Dell Streack with Android 2.2, that ICOSWorlsForcast Library runs in version 2.03 + 2.04, and not with version 2.5 .
 

lonleystar

Well-Known Member
Licensed User
Longtime User
I have now found on my Dell Streack with Android 2.2, that ICOSWorlsForcast Library runs in version 2.03 + 2.04, and not with version 2.5 .
hi paulsche i fix the library now work also with android 2.0. I'm sorry if I could not answer before because I'm studying Deutsch.

Tut mir leid, daß ich nicht vorher antworten konnte, habe Deutsch gelernt.

dont forget to rename from .zip to .rar

best regard

G.Salvi


Gruß G.Salvi
 

grant1842

Active Member
Licensed User
Longtime User
Thanks for all your support.

Did you find a way to use this in a service yet.

Thanks allot.
 

Paulsche

Well-Known Member
Licensed User
Longtime User
thanks for the update, :icon_clap:
my App now works under Android 2.2 .

Meine App funktioniert nun wieder unter Android 2.2.

danke.

Und noch viel Erfolg beim deutsch lernen !
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Will this lib support the POP: 96% in a future release ?
Thanks
hi grant1842, What u mean for POP: 96% in a future release.

I'm learning German and I'm a bit confused with 3 languages (Italian, English, German)

please tell me more about it.


best regard


G.Salvi
 

grant1842

Active Member
Licensed User
Longtime User
Ok.
On the website there is a P.O.P.
POSSIBILITY OF PRECIPITATION

I did not see support for it in the lib.
Thanks for your hard work.
Sent from my SCH-S720C using Tapatalk 2
 
Top