B4A Library ICOSWorldForecast 3.50

lonleystar

Well-Known 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:

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

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

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, 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
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 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. 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

I'm using library version 3.20..thank you for the time.
 

lonleystar

Well-Known Member
Licensed User
Longtime User

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 .
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 ), 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


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
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…