Android Question Understanding Widgets

leongcc

Member
Licensed User
Longtime User
I have a simplest implementation of a widget, codes for activity and service are below.

Appreciate anyone can explain some of my observations:

1) The activity is closed after it is created, but I can still see the activity name ("abc") in the list of running app in the Settings. It is registered there as long as my phone is on.

2) My phone came with several widgets, such as weather, etc..
Upon startup, I can see these widgets in the running app list, but they soon disappear.
Are there special widgets and standard widgets ?

3) The widget service StartAtBoot is not relevant because it is a widget and always start at boot ?



B4X:
#Region Module Attributes
    #ApplicationLabel: abc
#End Region

Sub Process_Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.Finish
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub


B4X:
Sub Process_Globals
    Dim rv As RemoteViews
    Dim myBeeper As Beeper
End Sub
Sub Service_Create
    rv = ConfigureHomeWidget("L1", "rv", 0, "xyz")  'Layout is just an empty panel
    myBeeper.Initialize(2000, 500)
End Sub

Sub Service_Start (StartingIntent As Intent)
    myBeeper.beep
End Sub

Sub rv_RequestUpdate
End Sub

Sub rv_Disabled
End Sub

Sub Service_Destroy
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Please use code tags when posting code!

codetag001.png

codetag002.png

codetag003.png
 
Upvote 0

leongcc

Member
Licensed User
Longtime User
1) Yes, I had meant the application name.
2) As described, my app does not do anything after startup, no updating. Why is it in the running list ?
 
Upvote 0

leongcc

Member
Licensed User
Longtime User
Just found.
Widget service explicitly requires StopService(Me), otherwise the app name will be at the runnlng list although the widget is not doing anything or scheduled to update anything.
 
Upvote 0
Top