Android Question Widget update causing an exception. why?

Levisvv

Member
Licensed User
Longtime User
So I have a very basic app that has a Widget service called 'Gate1' that launches the 'Doorgate1' RemoteView.
In that widget if a user touches a button, it opens the main routine.
This all works fine.
Within the main routine I have a button that should update an image on the widget but it causes an exception error.
Here is the command from my main routine:

Sub UnlockButton_Click
Gate1.Doorgate1.SetVisible("Locked",False)
Gate1.Doorgate1.SetVisible("Unlocked",True)
Gate1.Doorgate1.UpdateWidget

why cant I update the widget images from another module?
 

Levisvv

Member
Licensed User
Longtime User
If I try to run in debug mode to get meaningful error logs it crashes worse - here is the error logs (attached) from that.

But when compiled, I get the errors I am trying to fix only when in release mode, see the 2 attached pictures.
Here is my code for setting up one of my widgets, they are all very similar.

B4X:
#Region  Service Attributes
    #StartAtBoot: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public DoorGate1 As RemoteViews
   
End Sub

Sub Service_Create
    DoorGate1 = ConfigureHomeWidget("Gate", "gate1", 0, "Gate 1")
End Sub

Sub Service_Start (StartingIntent As Intent)
    If DoorGate1.HandleWidgetEvents(StartingIntent) Then Return
End Sub

Sub Service_Destroy

End Sub

Sub gate1_RequestUpdate
    DoorGate1.UpdateWidget
End Sub
Sub gate1_Disabled
    StopService("")
End Sub

Sub Gate1Button_Click
    Vars.CurrentType="Gate"
    Vars.CurrentID=1
   
    StartActivity(Main)
End Sub

and here is the code for my main routine that seems to crash when calling the RemoteView (widget) set commands and update command:
I tried declaring the remoteview varialbles in a code module called Vars as well as calling them within each widget service - both methods generate the same error per the attached pictures.

B4X:
Sub SliderUnlocked_Click
    SliderLocked.Visible=True
    SliderUnlocked.Visible=False
    'Wood, Double, Metal, Gate, Barrier, Sliding, Elevator, Overhead, Window, Light, Temp
    If Vars.CurrentType="Wood" Then
        If Vars.CurrentID=1 Then
            Vars.DoorWood1.SetVisible("Locked",True)
            Vars.DoorWood1.SetVisible("Unlocked",False)
            Vars.DoorWood1.UpdateWidget
        End If
    else If Vars.CurrentType="Double" Then
        If Vars.CurrentID=1 Then
            Vars.Doordouble1.SetVisible("Locked",True)
            Vars.Doordouble1.SetVisible("Unlocked",False)
            Vars.Doordouble1.UpdateWidget
        End If
    else If Vars.CurrentType="Metal" Then
        If Vars.CurrentID=1 Then
            Vars.Doormetal1.SetVisible("Locked",True)
            Vars.Doormetal1.SetVisible("Unlocked",False)
            Vars.Doormetal1.UpdateWidget
        End If
    else If Vars.CurrentType="Gate" Then
        If Vars.CurrentID=1 Then
            Gate1.Doorgate1.SetVisible("Locked",True)
            Gate1.Doorgate1.SetVisible("Unlocked",False)
            Gate1.Doorgate1.UpdateWidget
        End If
    End If
End Sub
 

Attachments

  • RemoteView widget update err.png
    RemoteView widget update err.png
    148.7 KB · Views: 190
  • RemoteView set widget image visible err.png
    RemoteView set widget image visible err.png
    176.7 KB · Views: 195
  • MQTTwidget Err log.txt
    3.6 KB · Views: 210
Upvote 0
Top