Help with HttpUtils2 error in a Service module

Peter Simpson

Expert
Licensed User
Longtime User
Hiya all,
Last night I decided to convert one of my Widgets projects from using HttpUtils to using Http2Utils. The following basic code works perfect in an 'Activity module', but in a ''Service module' I just keep getting the following error.

** Service (stardatewidget) Create **
** Service (stardatewidget) Start **
httpjob_download (java line: 77)
java.lang.NullPointerException

It appears to fall over on the following line which works in an 'Activity module'.

GetWeatherDataXML.Download("http://weather.yahooapis.com/forecastrss?w=2442047&u=c")

I've cut all the code out and just left the following code, I'm still getting the same error.

'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

Dim GetWeatherDataXML As HttpJob
Dim WeatherDataXML As String
Dim RV As RemoteViews
End Sub

Sub Service_Create
RV = ConfigureHomeWidget("testlayout", "RV", 30, "Test Weather Data", True)
End Sub

Sub Service_Start(StartingIntent As Intent)
GetWeatherDataXML.Initialize("GetWeatherDataXML", Me)
GetWeatherDataXML.Download("http://weather.yahooapis.com/forecastrss?w=2442047&u=c")
End Sub

Sub Service_Destroy
StopService("")
CancelScheduledService("")
End Sub

Sub JobDone(Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)

If Job.Success = True Then
Select Job.JobName
Case "GetWeatherDataXML"
WeatherDataXML = Job.GetString
Log(Job.GetString)
End Select
Else
ToastMessageShow("Oops: " & Job.ErrorMessage, True)
Log("Oops: " & Job.ErrorMessage)
End If

Job.Release
End Sub

Any help would be seriously appreciated as the above code works perfect in an 'Activity module' but falls over in an 'Service module'.

Thank you
Pete...
 

Peter Simpson

Expert
Licensed User
Longtime User
Wow, that did it.

You should download v2.02. It will probably fix this issue (it is hard to say without the full error message from the logs).

I've been looking through my code all night and the forums looking for a solution. I was going to create a bug report but thought I must be missing something and didn't want to look silly reporting a bug if there was not one(well, there was).

Anyway, as usual you have come up trumps with the answer and it worked even with my full project which I have know restored...

Thank you again Erel :)
 
Upvote 0
Top