Android Question Widget doesn't show up in widget list

rleiman

Well-Known Member
Licensed User
Longtime User
Hi,

I'm trying out a widget for the first time using this tutorial as a guide but the after running my app the widget does not show up in the widgets list of the phone.

I do know the service does get created as you can see in the attached code. Can you tell me what I missed?

Thanks.

Tutorial link: https://www.b4x.com/android/forum/threads/android-home-screen-widgets-tutorial-part-i.10166/

Code to start the service in the main module:

B4X:
Sub Activity_Create(FirstTime As Boolean)

    If FirstTime Then
        StartService(Widget)
    End If

Code from the service:

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

Sub Process_Globals
    Dim rv As RemoteViews
End Sub

Sub Service_Create
  
    ToastMessageShow("At the widget service.", True)
  
    rv = ConfigureHomeWidget("Widget", "rv", 0, "my widget")
End Sub

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

Sub Service_Destroy

End Sub

Sub rv_RequestUpdate
   rv.UpdateWidget
End Sub

Sub rv_Disabled
    StopService("")
End Sub
 

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Erel,

I made it smaller and removed the call to start the service and it now shows up on the list. :)
 
Upvote 0
Top