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: 778
  • ICOSWorldForecast_DEMO.part2.zip
    167.1 KB · Views: 613
  • Main.png
    Main.png
    86.8 KB · Views: 745
  • Widget.jpg
    Widget.jpg
    81.8 KB · Views: 757
  • ICOSWorldForecast.png
    ICOSWorldForecast.png
    156.3 KB · Views: 817
  • ICOSWorldForecastFree_v3.50_lib_fix.zip
    53.9 KB · Views: 359
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi all, ICOSWorldForecastFree is updated to v3.45 wath's new:

REMOVED

ParseWeatherFromItem

RequestConnectServer

and the unnecessary code and many bugs fixed.

the key is used now once per request not twice like before

please have a lock to the code below how it work.

********************************************​

B4X:
Sub a_LocationResult(Result As String, Value As Boolean)
    If (a.isWiFiConnected) Then
    If (Value) Then       
        If (a.ParseWeather(Result)) Then
            StartActivity(Forecast)
        Else
            toast.Show2("Message:",a.Message)
        End If
    End If
    Else
    toast.Show2("Message:","A data connection is requaired!!")
    End If
End Sub

Sub Activity_Resume

    If Not (a.IsTracking) Then
        a.UpdateLocation
    End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)

    If (UserClosed AND a.IsTracking) Then
        a.RemoveUpdates
    End If

End Sub


Sub b1_Click

    If (a.isWiFiConnected) Then
        If ed0.Text.Length > 0 Then
            If (a.ParseBySearchingCity(ed0.Text)) Then
                If (da.ParseWeather(ed0.Text,"ICOSWorld Forecast Demo v3.40",True)) Then
                    StartActivity(Forecast)
                Else
                    Return
                End If
            Else
                toast.Show2("Message:",a.Message)
            End If
        End If
    End If

End Sub

'************************ Or if U use listview or spinner from designer*******************

Sub b1_click

    l.Clear
    lv1.Clear
    If (a.IsWiFiConnected) Then
        If ed1.Text.Length > 0 Then
            If (a.ParseBySearchingCity(ed1.Text)) Then   --> instead of RequestConnectServer
                l=a.ParseCityList
                For n = 0 To l.Size-1
                    lv1.AddSingleLine(l.get(n))
                Next
            Else
                toast.Show(a.Message)
            End If
        End If
    End If

End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)

    If (a.ParseWeather(Value)) Then
        StartActivity(Forecast)
    Else
        toast.Show2("Message:",a.Message)
    End If
   
End Sub

Below the attached show the message error by using Message.​
 

Attachments

  • noapikey.jpg
    noapikey.jpg
    159.3 KB · Views: 117
  • keydisabled.jpg
    keydisabled.jpg
    160 KB · Views: 120
  • keyerror.jpg
    keyerror.jpg
    158.6 KB · Views: 119
  • unabletofindanymatching.jpg
    unabletofindanymatching.jpg
    157.9 KB · Views: 120
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Awesome!!! Thanks lonleystar!!!
 

Thraka

Member
Licensed User
Longtime User
Hi, have U download the new library? please do and let me know.

I'm having a problem with it. I tried this:
B4X:
If (forecastObject.ParseBySearchingCity("New York")) Then
    Dim desc As String
    desc = forecastObject.CCWeatherDesc     '<----- ERROR
Else

End If

Which doesn't work. The log says:
java.lang.NullPointerException
at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.getCCWeatherDesc(ICOSWorldForecastWrapper.java:1176)
 

lonleystar

Well-Known Member
Licensed User
Longtime User
I'm having a problem with it. I tried this:
B4X:
If (forecastObject.ParseBySearchingCity("New York")) Then
    Dim desc As String
    desc = forecastObject.CCWeatherDesc     '<----- ERROR
Else

End If

Which doesn't work. The log says:
java.lang.NullPointerException
at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.getCCWeatherDesc(ICOSWorldForecastWrapper.java:1176)

Hi, ParseBySearchingCity only check if the city exist or the provider reports any issue, it doesnt returns the weather's data.

ParseWeather returns the weather's data, look the code below.




B4X:
Sub b1_Click

    If (a.isWiFiConnected) Then
        If ed0.Text.Length > 0 Then
            If (a.ParseBySearchingCity(ed0.Text)) Then
                If (da.ParseWeather(ed0.Text,"ICOSWorld Forecast Demo v3.40",True)) Then
                    StartActivity(Forecast)
                Else
                    Return
                End If
            Else
                toast.Show2("Message:",a.Message)
            End If
        End If
    End If

End Sub

'************************ Or if U use listview or spinner from designer *******************

Sub b1_click

    l.Clear
    lv1.Clear
    If (a.IsWiFiConnected) Then
        If ed1.Text.Length > 0 Then
            If (a.ParseBySearchingCity(ed1.Text)) Then   --> instead of RequestConnectServer
                l=a.ParseCityList
                For n = 0 To l.Size-1
                    lv1.AddSingleLine(l.get(n))
                Next
            Else
                toast.Show(a.Message)
            End If
        End If
    End If

End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)

    If (a.ParseWeather(Value)) Then
        StartActivity(Forecast)
    Else
        toast.Show2("Message:",a.Message)
    End If

End Sub
 

Thraka

Member
Licensed User
Longtime User
Hi, ParseBySearchingCity only check if the city exist or the provider reports any issue, it doesnt returns the weather's data.

ParseWeather returns the weather's data, look the code below.
B4X:
[LEFT]
Sub b1_Click

    If (a.isWiFiConnected) Then
        If ed0.Text.Length > 0 Then
            If (a.ParseBySearchingCity(ed0.Text)) Then
                If (da.ParseWeather(ed0.Text,"ICOSWorld Forecast Demo v3.40",True)) Then    <------- Not sure what object da is, ParseWeather only has 1 parameter
                    StartActivity(Forecast)
                Else
                    Return
                End If
            Else
                toast.Show2("Message:",a.Message)
            End If
        End If
    End If

End Sub

'************************ Or if U use listview or spinner from designer *******************

Sub b1_click

    l.Clear
    lv1.Clear
    If (a.IsWiFiConnected) Then
        If ed1.Text.Length > 0 Then
            If (a.ParseBySearchingCity(ed1.Text)) Then   --> instead of RequestConnectServer
                l=a.ParseCityList
                For n = 0 To l.Size-1
                    lv1.AddSingleLine(l.get(n))
                Next
            Else
                toast.Show(a.Message)
            End If
        End If
    End If

End Sub

Sub lv1_ItemClick (Position As Int, Value As Object)

    If (a.ParseWeather(Value)) Then
        StartActivity(Forecast)
    Else
        toast.Show2("Message:",a.Message)
    End If

End Sub
[/LEFT]

I did try that but got the same error. At first I had this:
B4X:
If (forecastObject.ParseBySearchingCity("New York")) Then
    Dim desc As String

    forecastObject.ParseWeather("New York")
    desc = forecastObject.CCWeatherDesc     '<----- ERROR
Else

End If

Additionally, I don't know what this code in your sample does:
B4X:
 If (da.ParseWeather(ed0.Text,"ICOSWorld Forecast Demo v3.40",True)) Then '  <------- Not sure what object da is, ParseWeather only has 1 parameter
 

sdb

Member
Licensed User
Longtime User
I am having the same type of problem when recompiling my program from an earlier version. My api key is correct, it was working previously and I confirmed it with World Weather. I am using B4A 4.0 and ICOSWorldForecast 3.45.

The a.ParseWeather("xxx") returns a true value but when I try to access any data element it fails as above.

I have tried various approaches but no luck.

Also, your da.ParseWeather line in the example has 3 parameters not 1. Not sure I understand how that is working at all.

Thanks,
 

MarcoRome

Expert
Licensed User
Longtime User
I am having the same type of problem when recompiling my program from an earlier version. My api key is correct, it was working previously and I confirmed it with World Weather. I am using B4A 4.0 and ICOSWorldForecast 3.45.

The a.ParseWeather("xxx") returns a true value but when I try to access any data element it fails as above.

I have tried various approaches but no luck.

Also, your da.ParseWeather line in the example has 3 parameters not 1. Not sure I understand how that is working at all.

Thanks,

strain... if you copy a few code maybe is better to help you :
anyway this code work for me
leggimeteo.Initialize("leggimeteo")
leggimeteo.ApiKey = "XXXXXXXX"

citta = leggimeteo.FindLocation
If leggimeteo.ParseWeather(citta) = False Then
citta = leggimeteo.LocalIpAddress
End If

lbmeteo.Text = leggimeteo.AreaName & " - " & "Temperature: C° " & leggimeteo.CCTempCelsius & " (" & leggimeteo.FCTempMinCelsius(0) & "C°|" & leggimeteo.FCTempMaxCelsius(0) & "C°) - " & "F° " & leggimeteo.CCTempFahrenheit & " (" & leggimeteo.FCTempMinFahrenheit(0) & "F°|" & leggimeteo.FCTempMaxFahrenheit(0) & "F°)" & CRLF & _
"Umididty " & leggimeteo.CCHumidity & "% - " Pressure: " & leggimeteo.CCPressure

lbmeteo.Text = lbmeteo.Text.ToUpperCase

lboggi.Text = lingue.meteo_oggi
lbdomani.Text = lingue.meteo_domani

ImageView1.Bitmap = leggimeteo.FCIcon(0)
ImageView2.Bitmap = leggimeteo.FCIcon(1)

Bye
 

sdb

Member
Licensed User
Longtime User
Here is the code that is executing. 'Title' is the location passed to the routine. I get the error on the last line.
B4X:
a.Initialize("a")
a.ApiKey="xxxxxxxxxxxxxxxxx"
If a.ParseWeather(Title) = False Then
    Msgbox ("ParseWeather Failure", "Error")
End If
strTest = a.FCTempMinFahrenheit(0)

Here is the error:

** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 170 (main)
java.lang.NullPointerException
at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.FCTempMinFahrenheit(ICOSWorldForecastWrapper.java:669)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at sb.weathertabs.main.afterFirstLayout(main.java:104)
at sb.weathertabs.main.access$100(main.java:16)
at sb.weathertabs.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4911)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
 

MarcoRome

Expert
Licensed User
Longtime User
Error in ParseWeather ???

Hi Giuseppe, i have this code that until one week ago work without problem.
Today i have this situation:

B4X:
'If ph.GetDataState <> "CONNECTED" OR myLAN.GetMyIP = "127.0.0.1" Then
If myLAN.GetMyIP = "127.0.0.1" Then
                  ToastMessageShow(lingue.conn_internet, True)      
                ImageView1.Visible = False
                ImageView2.Visible = False
Else
' Testo se la connessione è ok e se restituisce il risultato
Try

        leggimeteo.Initialize("leggimeteo")
        leggimeteo.ApiKey =  "m7sutqf7uxdbr6xxxXXXXXX"
       
  

                    citta = leggimeteo.FindLocation
                    If leggimeteo.ParseWeather(citta) = False Then
                        citta = leggimeteo.LocalIpAddress
                    End If
                    If GetDeviceLayoutValues.ApproximateScreenSize < 5 Then
                            lbmeteo.TextSize = 11
                    End If
                            lbmeteo.Text = leggimeteo.AreaName & " - " & lingue.temperatura_ins & ": C° " & leggimeteo.CCTempCelsius & " (" & leggimeteo.FCTempMinCelsius(0) & "C°|" & leggimeteo.FCTempMaxCelsius(0) & "C°) - " & "F° " & leggimeteo.CCTempFahrenheit & " (" & leggimeteo.FCTempMinFahrenheit(0) & "F°|" & leggimeteo.FCTempMaxFahrenheit(0) & "F°)" & CRLF & _
                            lingue.umidita & leggimeteo.CCHumidity & "% - " &lingue.pressione & leggimeteo.CCPressure
                            lbmeteo.Text = lbmeteo.Text.ToUpperCase




                    lboggi.Text = lingue.meteo_oggi
                    lbdomani.Text = lingue.meteo_domani
      
                    ImageView1.Bitmap = leggimeteo.FCIcon(0)
                    ImageView2.Bitmap = leggimeteo.FCIcon(1)

Catch
'.... Non visualizzo Errore e inserisco non visibili imageview1 e 2
ToastMessageShow(lingue.conn_internet, True)
'ToastMessageShow(leggimeteo.Message, True)

citta = i have "Value right" ( as you can see in this pictures - and so the key work ) but when go in this line
Screenshot 2015-03-14 09.07.02.png

B4X:
If leggimeteo.ParseWeather(citta) = False

i have this error:

B4X:
** Activity (main) Create, isFirst = true **
Error occurred on line: 277 (main)
java.lang.NullPointerException
    at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.ParseWeather(ICOSWorldForecastWrapper.java:404)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at com.devil.app.night.clock.main.afterFirstLayout(main.java:100)
    at com.devil.app.night.clock.main.access$100(main.java:17)
    at com.devil.app.night.clock.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5692)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)

Screenshot 2015-03-14 09.07.20.png




Change any function in SDK or what.

Any Idea ???

Thank you
Marco
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Error in ParseWeather ???

Hi Giuseppe, i have this code that until one week ago work without problem.
Today i have this situation:

B4X:
'If ph.GetDataState <> "CONNECTED" OR myLAN.GetMyIP = "127.0.0.1" Then
If myLAN.GetMyIP = "127.0.0.1" Then
                  ToastMessageShow(lingue.conn_internet, True)     
                ImageView1.Visible = False
                ImageView2.Visible = False
Else
' Testo se la connessione è ok e se restituisce il risultato
Try

        leggimeteo.Initialize("leggimeteo")
        leggimeteo.ApiKey =  "m7sutqf7uxdbr6xxxXXXXXX"
      
 

                    citta = leggimeteo.FindLocation
                    If leggimeteo.ParseWeather(citta) = False Then
                        citta = leggimeteo.LocalIpAddress
                    End If
                    If GetDeviceLayoutValues.ApproximateScreenSize < 5 Then
                            lbmeteo.TextSize = 11
                    End If
                            lbmeteo.Text = leggimeteo.AreaName & " - " & lingue.temperatura_ins & ": C° " & leggimeteo.CCTempCelsius & " (" & leggimeteo.FCTempMinCelsius(0) & "C°|" & leggimeteo.FCTempMaxCelsius(0) & "C°) - " & "F° " & leggimeteo.CCTempFahrenheit & " (" & leggimeteo.FCTempMinFahrenheit(0) & "F°|" & leggimeteo.FCTempMaxFahrenheit(0) & "F°)" & CRLF & _
                            lingue.umidita & leggimeteo.CCHumidity & "% - " &lingue.pressione & leggimeteo.CCPressure
                            lbmeteo.Text = lbmeteo.Text.ToUpperCase




                    lboggi.Text = lingue.meteo_oggi
                    lbdomani.Text = lingue.meteo_domani
     
                    ImageView1.Bitmap = leggimeteo.FCIcon(0)
                    ImageView2.Bitmap = leggimeteo.FCIcon(1)

Catch
'.... Non visualizzo Errore e inserisco non visibili imageview1 e 2
ToastMessageShow(lingue.conn_internet, True)
'ToastMessageShow(leggimeteo.Message, True)

citta = i have "Value right" ( as you can see in this pictures - and so the key work ) but when go in this line
View attachment 32865
B4X:
If leggimeteo.ParseWeather(citta) = False

i have this error:

B4X:
** Activity (main) Create, isFirst = true **
Error occurred on line: 277 (main)
java.lang.NullPointerException
    at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.ParseWeather(ICOSWorldForecastWrapper.java:404)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at com.devil.app.night.clock.main.afterFirstLayout(main.java:100)
    at com.devil.app.night.clock.main.access$100(main.java:17)
    at com.devil.app.night.clock.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5692)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)

View attachment 32866



Change any function in SDK or what.

Any Idea ???

Thank you
Marco


Ciao Marco, the server change the request url, but I'll change and update the librari sorry for the inconvenient.
 

MarcoRome

Expert
Licensed User
Longtime User
Thank you Giuseppe.
Now this code:
B4X:
citta = leggimeteo.FindLocation
                    If leggimeteo.ParseWeather(citta) = False Then
                        citta = leggimeteo.LocalIpAddress
                    End If
work... but all property CRASH...
example:
B4X:
lbmeteo.Text =  leggimeteo.CCTempCelsius
but also another property have same problem

and this is message:

B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.devil.app.night.clock
** Activity (main) Create, isFirst = true **

java.lang.NullPointerException
    at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.getCCTempCelsius(ICOSWorldForecastWrapper.java:1137)
    at com.devil.app.night.clock.main._carica_meteo(main.java:853)
    at com.devil.app.night.clock.main._activity_create(main.java:581)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at com.devil.app.night.clock.main.afterFirstLayout(main.java:100)
    at com.devil.app.night.clock.main.access$100(main.java:17)
    at com.devil.app.night.clock.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5692)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **

maybe is change also SDK ?
 

Laurent95

Active Member
Licensed User
Longtime User
Hello Giuseppe,

How i can use the weather by IP now ?
Thanks for say me if it's always possible.

Regards, Laurent.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Thank you Giuseppe.
Now this code:
B4X:
citta = leggimeteo.FindLocation
                    If leggimeteo.ParseWeather(citta) = False Then
                        citta = leggimeteo.LocalIpAddress
                    End If
work... but all property CRASH...
example:
B4X:
lbmeteo.Text =  leggimeteo.CCTempCelsius
but also another property have same problem

and this is message:

B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.devil.app.night.clock
** Activity (main) Create, isFirst = true **

java.lang.NullPointerException
    at it.giuseppe.salvi.library.core.ICOSWorldForecastWrapper.getCCTempCelsius(ICOSWorldForecastWrapper.java:1137)
    at com.devil.app.night.clock.main._carica_meteo(main.java:853)
    at com.devil.app.night.clock.main._activity_create(main.java:581)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at com.devil.app.night.clock.main.afterFirstLayout(main.java:100)
    at com.devil.app.night.clock.main.access$100(main.java:17)
    at com.devil.app.night.clock.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5692)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **

maybe is change also SDK ?


Hi marco be patience because WorldWeatherOnline still not work some time yes but the most of the day it still not working.

I get the same error because it doesnt find the date.
 
Top