I am using this service code:
as part of a simple widget test. The activity (Main) simply loads a layout file with some text boxes on it. the activity code for that is
However when I install to the emulator the main screen comes up immediately after installation. When I dismiss the window and add the widget it does show but I get an immediate error that the app has stopped unexpectedly and have to click the force close button after which the widget is shown but is not clickable (the addcontacts part of the service code is a clickable image view that when clicked should call the main activity) and the emulator shows this error:
My code is very simple and I was trying to see how I get widgets to work but can't seem to get a simple widget working, any ideas where I have gone wrong?
Dave
B4X:
'Service module
Sub Process_Globals
Dim rv As RemoteViews
End Sub
Sub Service_Create
rv = ConfigureHomeWidget("WidgetLayout", "rv", 0, "Add contacts")
End Sub
Sub Service_Start (StartingIntent As Intent)
If rv.HandleWidgetEvents(StartingIntent) Then Return
End Sub
Sub rv_RequestUpdate
rv.UpdateWidget
End Sub
Sub addcontacts_Click
StartActivity(Main)
End Sub
Sub rv_Disabled
StopService("")
End Sub
Sub Service_Destroy
End Sub
as part of a simple widget test. The activity (Main) simply loads a layout file with some text boxes on it. the activity code for that is
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("mainscreen.bal")
End Sub
However when I install to the emulator the main screen comes up immediately after installation. When I dismiss the window and add the widget it does show but I get an immediate error that the app has stopped unexpectedly and have to click the force close button after which the widget is shown but is not clickable (the addcontacts part of the service code is a clickable image view that when clicked should call the main activity) and the emulator shows this error:
B4X:
java.lang.Exception: Sub service_start signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:107)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:89)
at AddContacts.com.widgetservice.handleStart(widgetservice.java:61)
at AddContacts.com.widgetservice.onStartCommand(widgetservice.java:46)
My code is very simple and I was trying to see how I get widgets to work but can't seem to get a simple widget working, any ideas where I have gone wrong?
Dave