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: 887
  • ICOSWorldForecast_DEMO.part2.zip
    167.1 KB · Views: 703
  • Main.png
    Main.png
    86.8 KB · Views: 852
  • Widget.jpg
    Widget.jpg
    81.8 KB · Views: 842
  • ICOSWorldForecast.png
    ICOSWorldForecast.png
    156.3 KB · Views: 906
  • ICOSWorldForecastFree_v3.50_lib_fix.zip
    53.9 KB · Views: 451
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Giuseppe,

Thank you for update the library again.
I need some explains about the new functions.
1) If i don't use the FromLocation or FromLatAndLong, i don't need to use the callback for cancel the timer in my code, right ?
2) Other question about this two new functions, what they returns exactly ? Only the city or other data ? i bet you use the geoname api for this and in my widget i give the possibility to find a place on a map. Maybe the new function can help me to retrieve the exact place with lat & long for a city. But not sure, i need other data also, it's why i ask you what you get as data in this way.
Another, but related to the next post, how you, or we, can determine which ISO code is used for the website ?
On the Website they say :

But i don't see anywhere in functions how i can put a special ISO code.
I think it's good for the spelling in each language to search a city. It can help, for example Manila in English it's Manille in French.
And who knows maybe we can search a city with Walof spelling, soon when we have learned it :eek:

Thank you in advance for your help, the library works good and grows up time after time.

Best regards.
Laurent

Hi Laurent, for the first question U really dont need if U dont use FromLatAndLong and FromLocation, but if U use or U use only the LocationResult U need exampl:

B4X:
Sub a_LocationResult(Result As String, Value As Boolean)
    If (Value) Then
        a.CityName = Result
        StartActivity(Forecast)
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   a.CancelTimer
End Sub

For the second question:

From LocationResult(Result As String, Value As Boolean): the Result return the location and Value true when got location.

FromLatAndLong and FromLocation instead of FindLatAndLong and FindLocation they return exactly the location and coordinates by ( GPS or WI-FI ).
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, for the first question U really dont need if U dont use FromLatAndLong and FromLocation, but if U use or U use only the LocationResult U need exampl:

For the second question:

From LocationResult(Result As String, Value As Boolean): the Result return the location and Value true when got location.

FromLatAndLong and FromLocation instead of FindLatAndLong and FindLocation they return exactly the location and coordinates by ( GPS or WI-FI ).

Ok Giuseppe,
Thank you for the response, it's clear.
But for the ISO code needed for find a city with another spelling, can you tell us how we must use it ?
I mean can we do it directly with the library or we need to do a Sub for that ?

Thank you for respond always to our questions, it's cool :)

Best regards, Laurent.
 
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
Ok Giuseppe,
Thank you for the response, it's clear.
But for the ISO code needed for find a city with another spelling, can you tell us how we must use it ?
I mean can we do it directly with the library or we need to do a Sub for that ?

Thank you for respond always to our questions, it's cool :)

Best regards, Laurent.

Hi Laurent, U can still use GetCityList.

P.S.
if I misunderstood please an example.
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, U can still use GetCityList.

P.S.
if I misunderstood please an example.

Hi Giuseppe,

Let that, you can't do more, that is the Website who is not clear.
When they told about many languages, there is only the description of forecast who is translate.
I have try directly on the website those two request :
http://api.worldweatheronline.com/free/v1/weather.ashx?q=Manila&key=xxxxxxxxxxxxxxxxx&lang=fr
But
http://api.worldweatheronline.com/free/v1/weather.ashx?q=Manille&key=xxxxxxxxxxxxxxxxx&lang=fr
That still no city but an error in the XML with the French spelling.
<data>
<error>
<msg>Unable to find any matching weather location to the query submitted!
</msg>
</error>
</data>
Even Manille is the correct spelling for Manila the Website don't recognize it like a city.
And of course i use GetCityList :)

Sorry for the inconvenience.

Best regards.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Giuseppe,

Let that, you can't do more, that is the Website who is not clear.
When they told about many languages, there is only the description of forecast who is translate.
I have try directly on the website those two request :
http://api.worldweatheronline.com/free/v1/weather.ashx?q=Manila&key=xxxxxxxxxxxxxxxxx&lang=fr
But
http://api.worldweatheronline.com/free/v1/weather.ashx?q=Manille&key=xxxxxxxxxxxxxxxxx&lang=fr
That still no city but an error in the XML with the French spelling.

Even Manille is the correct spelling for Manila the Website don't recognize it like a city.
And of course i use GetCityList :)

Sorry for the inconvenience.

Best regards.

Hi, U'r right the provider does not give the right spelling and the translation is just for the description of forecast.
 

Thraka

Member
Licensed User
Longtime User
For some reason when I do a search on a fake name like TEST2 and it comes back with an exception that I've trapped, it kills the program. Apparently Activity_Pause gets called for me.

Does anyone else have this problem?
 

Laurent95

Active Member
Licensed User
Longtime User
For some reason when I do a search on a fake name like TEST2 and it comes back with an exception that I've trapped, it kills the program. Apparently Activity_Pause gets called for me.

Does anyone else have this problem?

Hello,

It's not possible to respond to you without the code.
Send your project in zip file or at least the code you use for trap the exception and when that kills the program.
Maybe someone could help you then.
 

Laurent95

Active Member
Licensed User
Longtime User
Hello Giuseppe,

It seems i can't have an update of datas when i use the function
a.WeaterByLocalIpAddress=a.LocalIpAddress
All time that gives me the data of the city precedently used.
Can you take a look please ?
I don't think i do a mistake in the call.

Thank you by advance.

Regards, Laurent
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hello Giuseppe,

It seems i can't have an update of datas when i use the function
a.WeaterByLocalIpAddress=a.LocalIpAddress
All time that gives me the data of the city precedently used.
Can you take a look please ?
I don't think i do a mistake in the call.

Thank you by advance.

Regards, Laurent
Hi Laurent, Try tu use Dim l As List l=GetList everytimes U call GetList, the list doesnt cancell the date precedently used.

P.S.

It work fine but I dont understand why when I use it after give always the date precedently used.

I'll check it tomorrow.
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent, Try tu use Dim l As List l=GetList everytimes U call GetList, the list doesnt cancell the date precedently used.

P.S.

It work fine but I dont understand why when I use it after give always the date precedently used.

I'll check it tomorrow.

Hi Giuseppe,

OK but what i means it's on the call about localIP that seems not change anything and let all data are the same of precedent place.
If i use this function i retrieves all data who are related with the precedent city it is used, not the data for the local IP place even if i am in France and the precedent city is in USA or where you want.
I have try to call immediately after the function local IP to use the function FromLocation, then when i restart the configuration app that's give the good data but also an error because i can't cancel the timer on a widget :(

I will try tomorrow to make an example on an activity, for now that's what i see on my widget.

Thanks for your support.

Laurent.
 

microbox

Active Member
Licensed User
Longtime User
Hello, I'm back to try this great library. But I'm having a force close when running the program.
I copied the logs.
B4X:
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException:  Probably server error!! 
    at it.giuseppe.salvi.icos.library.weather.forecast.provider.ICOSForecastWrapper$ICOSBackgroundWorkGetWeaterAsync.doInBackground(ICOSForecastWrapper.java:108)
    at it.giuseppe.salvi.icos.library.weather.forecast.provider.ICOSForecastWrapper$ICOSBackgroundWorkGetWeaterAsync.doInBackground(ICOSForecastWrapper.java:1)
    at android.os.AsyncTask$2.call(AsyncTask.java:264)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    at java.lang.Thread.run(Thread.java:856)
java.util.concurrent.ExecutionException: java.lang.NullPointerException:  Probably server error!! 
** Activity (main) Pause, UserClosed = true **
** Activity (forecast) Resume **
Can anyone help me out what I'm doing bad?

Thanks in advance
 

microbox

Active Member
Licensed User
Longtime User
I did some changes...but still gives me the following error
Logs:
B4X:
    at giuseppe.salvi.icosworldforecast.forecast._weather(forecast.java:462)
    at giuseppe.salvi.icosworldforecast.forecast._activity_create(forecast.java:329)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
    at giuseppe.salvi.icosworldforecast.forecast.afterFirstLayout(forecast.java:98)
    at giuseppe.salvi.icosworldforecast.forecast.access$100(forecast.java:16)
    at giuseppe.salvi.icosworldforecast.forecast$WaitForLayout.run(forecast.java:76)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.StringIndexOutOfBoundsException: length=0; regionStart=10; regionLength=6
 

microbox

Active Member
Licensed User
Longtime User
I fix my issue above...my only concern is that every time it run, there is a message that says "program...not responding", so I just click on wait button. Can I resolve it?
 

lonleystar

Well-Known Member
Licensed User
Longtime User
I fix my issue above...my only concern is that every time it run, there is a message that says "program...not responding", so I just click on wait button. Can I resolve it?

Hi, I really dont know I dont get this issue. Just tried now and get it work without issue.

P.S.

Can U send The code so I can check it also via email if U dont wont share your code with other peopple.
 

microbox

Active Member
Licensed User
Longtime User
Hello lonleystar, I'm sure it's probably just me:oops:. I'm just want to run the example you gave so that I can include it in my application. It's giving some error.
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: ICOSWorldForecast
    #VersionCode: 272
    #VersionName: 2.72
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
    Dim mGetList,mCityname As String
    Dim mBoolean As Boolean
    Dim a As ICOSWorldForecastFree   
End Sub

Sub Globals
    Dim ed1,ed2 As EditText
    Dim lv1 As ListView
    Dim l As List
    Dim l1,l2 As Label
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("weather")
    a.Initialize("a")   
    a.ApiKey="uhfa4kbbdkyxs9gsy9efj458"   
    Activity.AddMenuItem("Exit","exit")
    Activity.Title="ICOSWorldForecast Library v2.78 - Giuseppe Salvi"
    ed1.TextColor=Colors.White
    ed2.TextColor=Colors.White   
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub b1_click
If a.isWiFiConnected = True Then
    lv1.Clear
    mBoolean= False
    mGetList=ed1.Text
    If mGetList.Length > 0 Then
    l=a.GetCityList(mGetList)
    For n = 0 To l.Size-1
    lv1.AddSingleLine(l.Get(n))
    Next
    End If
    End If
End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)
    mGetList=lv1.GetItem(Position)
    StartActivity(Forecast)
    CallSub(Forecast,mGetList)
   
End Sub


Sub b2_click
    mBoolean = True
    mCityname=ed2.Text
    If mCityname.Length > 0 Then
    StartActivity(Forecast)
    CallSub(Forecast,mCityname)
    End If
End Sub

Sub exit_click
    ExitApplication
End Sub
ScreenShot1.png
I'm using library version 3.20..thank you for the time.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hello lonleystar, I'm sure it's probably just me:oops:. I'm just want to run the example you gave so that I can include it in my application. It's giving some error.
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: ICOSWorldForecast
    #VersionCode: 272
    #VersionName: 2.72
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
    Dim mGetList,mCityname As String
    Dim mBoolean As Boolean
    Dim a As ICOSWorldForecastFree  
End Sub

Sub Globals
    Dim ed1,ed2 As EditText
    Dim lv1 As ListView
    Dim l As List
    Dim l1,l2 As Label
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("weather")
    a.Initialize("a")  
    a.ApiKey="uhfa4kbbdkyxs9gsy9efj458"  
    Activity.AddMenuItem("Exit","exit")
    Activity.Title="ICOSWorldForecast Library v2.78 - Giuseppe Salvi"
    ed1.TextColor=Colors.White
    ed2.TextColor=Colors.White  
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub b1_click
If a.isWiFiConnected = True Then
    lv1.Clear
    mBoolean= False
    mGetList=ed1.Text
    If mGetList.Length > 0 Then
    l=a.GetCityList(mGetList)
    For n = 0 To l.Size-1
    lv1.AddSingleLine(l.Get(n))
    Next
    End If
    End If
End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)
    mGetList=lv1.GetItem(Position)
    StartActivity(Forecast)
    CallSub(Forecast,mGetList)
  
End Sub


Sub b2_click
    mBoolean = True
    mCityname=ed2.Text
    If mCityname.Length > 0 Then
    StartActivity(Forecast)
    CallSub(Forecast,mCityname)
    End If
End Sub

Sub exit_click
    ExitApplication
End Sub
View attachment 27972
I'm using library version 3.20..thank you for the time.

Hi, I'll check it tomorrow any ´way I'm working on it to understand why by getlist it give always the first city.
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent and all, the ICOSWorldForecast is updated to v3.30 nothing has been changed but fixed the bug Laurent as reported.

P.S.

I decided to remove all old version because they had the same bug.

Hi Giuseppe,

You're the best yeahhhhhhhh :)
It work fine now with the local IP address and return the right city where my provider is based.
Not my city of course, but until this update, that return me the last city even it's in another country :eek:.
I will continue other tests with "FromLocation" and all around, but i guess it's not changed.
Thank you very much for maintain the library really good, and for your time you give us, for have always the best, congrats !

Laurent.

P.S. : For all who use the library, (it's my case, i still use the ICOSForecastGetList and da.GetCityList("ATown") for fill a list somewhere, i don't know why :confused:), this function isn't maintained in this version, you must use the library "GetCityList" function who work like a charm now ;)
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hello lonleystar, I'm sure it's probably just me:oops:. I'm just want to run the example you gave so that I can include it in my application. It's giving some error.
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: ICOSWorldForecast
    #VersionCode: 272
    #VersionName: 2.72
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
    Dim mGetList,mCityname As String
    Dim mBoolean As Boolean
    Dim a As ICOSWorldForecastFree  
End Sub

Sub Globals
    Dim ed1,ed2 As EditText
    Dim lv1 As ListView
    Dim l As List
    Dim l1,l2 As Label
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("weather")
    a.Initialize("a")  
    a.ApiKey="uhfa4kbbdkyxs9gsy9efj458"  
    Activity.AddMenuItem("Exit","exit")
    Activity.Title="ICOSWorldForecast Library v2.78 - Giuseppe Salvi"
    ed1.TextColor=Colors.White
    ed2.TextColor=Colors.White  
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub b1_click
If a.isWiFiConnected = True Then
    lv1.Clear
    mBoolean= False
    mGetList=ed1.Text
    If mGetList.Length > 0 Then
    l=a.GetCityList(mGetList)
    For n = 0 To l.Size-1
    lv1.AddSingleLine(l.Get(n))
    Next
    End If
    End If
End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)
    mGetList=lv1.GetItem(Position)
    StartActivity(Forecast)
    CallSub(Forecast,mGetList)
  
End Sub


Sub b2_click
    mBoolean = True
    mCityname=ed2.Text
    If mCityname.Length > 0 Then
    StartActivity(Forecast)
    CallSub(Forecast,mCityname)
    End If
End Sub

Sub exit_click
    ExitApplication
End Sub
View attachment 27972
I'm using library version 3.20..thank you for the time.


Hi, try this fixed below

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: ICOSWorldForecast
    #VersionCode: 272
    #VersionName: 2.72
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
    Dim mGetList,mCityname As String
    Dim mBoolean As Boolean
    Dim a As ICOSWorldForecastFree  
End Sub

Sub Globals
    Dim ed1,ed2 As EditText
    Dim lv1 As ListView
    Dim l As List
    Dim l1,l2 As Label
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("weather")
    a.Initialize("a")  
    a.ApiKey="uhfa4kbbdkyxs9gsy9efj458"  
    Activity.AddMenuItem("Exit","exit")
    Activity.Title="ICOSWorldForecast Library v2.78 - Giuseppe Salvi"
    ed1.TextColor=Colors.White
    ed2.TextColor=Colors.White  
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub b1_click
If a.isWiFiConnected = True Then
    lv1.Clear
    mBoolean= False
    mGetList=ed1.Text
    If mGetList.Length > 0 Then
    l=a.GetCityList(mGetList)
    For n = 0 To l.Size-1
    lv1.AddSingleLine(l.Get(n))
    Next
    End If
    End If
End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)
    mGetList=lv1.GetItem(Position)
    a.CityName = mCityname
    StartActivity(Forecast)
End Sub


Sub b2_click
    mBoolean = True
    mCityname=ed2.Text
    If mCityname.Length > 0 Then
    a.CityName = mCityname
    StartActivity(Forecast)
  
    End If
End Sub

Sub exit_click
    ExitApplication
End Sub
 
Top