Panel1_Click doesn't work after creating the widget

cmweb

Active Member
Licensed User
Longtime User
Hello,

I build a small widget that features a Panel1_Click Event with the StartActivity(Main) call.

Unfurtunately, that click event doesn't work after creating the widget.

The click event only works after the widget gets a CallSub(widget, "Widget_check") from an other service.

What can I do to have the Panel1_click working even if the widget has not been called yet from an other service?

Code for the widget is:

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

    Dim rv As RemoteViews

End Sub
Sub Service_Create
    
    rv = ConfigureHomeWidget("widglayout.bal", "rv", 0, "Parkzone Dialer Widget", True)

End Sub

Sub Service_Start (StartingIntent As Intent)

   If rv.HandleWidgetEvents(StartingIntent) Then Return
 
End Sub

Sub rv_RequestUpdate

End Sub

Sub rv_Disabled
    StopService("")
End Sub

Sub Service_Destroy

End Sub

Sub Widget_check
   rv.SetVisible("Label1", True)
   rv.SetVisible("ImageView1", False)
   rv.SetVisible("Label2", True)
   rv.SetText("Label1", Parktime.gesamtminuten)
   rv.UpdateWidget
End Sub

Sub Widget_Stop
   rv.SetVisible("Label1", False)
   rv.SetVisible("ImageView1", True)
   rv.SetVisible("Label2", False)
    rv.UpdateWidget
End Sub

Sub Panel1_Click
   StartActivity(Main)
End Sub

After calling from an other service

B4X:
CallSub(widget, "Widget_check")

the Panel1_click works... But how can the click event work without calling the widget from outside?

Best regards,
Carsten
 

cmweb

Active Member
Licensed User
Longtime User
Hi Erel,

me again. Several months later, I'm having the same problem. Panel1_click doesn't fire... but why?

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

'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 rv As RemoteViews

End Sub
Sub Service_Create
   
    rv = ConfigureHomeWidget("widglayout.bal", "rv", 0, "MyWidget", True)

End Sub

Sub Service_Start (StartingIntent As Intent)

    If rv.HandleWidgetEvents(StartingIntent) Then Return
End Sub

Sub rv_RequestUpdate

    rv.UpdateWidget

End Sub

Sub rv_Disabled
    StopService("")
End Sub

Sub Service_Destroy

End Sub

Sub Widget_check
    rv.UpdateWidget
End Sub

Sub Widget_Stop
    rv.UpdateWidget
End Sub

Sub Panel1_Click
    StartActivity(Main)
End Sub

Thanks for your help...

Best regards,

Carsten
 
Upvote 0

cmweb

Active Member
Licensed User
Longtime User
Hi Erel,

works now... It seems that it took several minutes after placing the widget on the homescreen until it works... So I just had to wait... don't know why...

Btw, in earlier versions of Basic4Android I could use 72x72 size for a 1x1 widget. Now with the current B4A version, a widget of 72x72 size will result in a 2x1 widget. I have to reduce to 60x60... What is the reason for that?

Does the StartAtBoot Attribute (true/false) have any impact for the widget service?

Best regards,

Carsten
 
Upvote 0
Top