very simple widget test fails but not sure why

mistermentality

Active Member
Licensed User
Longtime User
I am using this service code:

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
 

mistermentality

Active Member
Licensed User
Longtime User
It's a fresh install of v1.6, I deleted all old program files after uninstalling previous version before installing the new one so shouldn't the libraries be correct?

Core is 1.57 but unsure about B4Ashared, just reinstalled again and still same problem :(

Dave

Edit: I physically deleted the library files and reinstalled and the versions are the same so I think I must have the right version as only have the 1.6 exe to install from.
 
Last edited:
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
Check if you have an "additional libraries folder" set. It should appear under Tools - Configure Paths. This error might happen if you are using an older version of Phone library in your project. The version of Phone library should be 1.55.

Phone library is 1.55 and no additional libraries path set :(

Dave
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
Can you manually zip your whole project and upload it? It needs to be done manually as I need the src folder to be included.

I have added it here. I have commented out all other code except literally the load layout part and still have the same errors so please excuse the lots of commented out test code.

Dave
 
Last edited:
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
I have tried it now on four emulators and all do the same thing. I hadn't tried it on my phone as wanted to get it working on emulator first so could check scaling etc but you are right it does work on an actual device just not in any emulators I have.

Dave
 
Upvote 0

mistermentality

Active Member
Licensed User
Longtime User
My default emulator is the same as my actual device 2.2, the others were 1.6 and 2.1. The emulator that emulates my device won't run it correctly but the device will, am puzzled why but I can test it on my device just will not be able to test on emulator until I can find out the cause but if it is working for you on an emulator there must be something wrong with my emulators.

Dave

Edit: I recreated the emulator of my device and it now does work, others don't but I think although not sure how it could happen maybe a file the emulators need to work was damaged somehow. It works in newly made emulator though thank you :)
 
Last edited:
Upvote 0
Top