Based on the widget example https://www.b4x.com/android/forum/threads/android-home-screen-widgets-tutorial-part-i.10166/ I added a widget to and already existing B4XPages app.
The widget displays the bitmap taken with the Snapshot method from a B4XView.
The B4XView is available only when the app is running, while the widget service receives updates requests even when the app is not running.
Here is the code from the Widget service: what I see in the logs, is that the RequestUpdate gets called, but B4XPages is not available, thus skipping widget update
The widget displays the bitmap taken with the Snapshot method from a B4XView.
The B4XView is available only when the app is running, while the widget service receives updates requests even when the app is not running.
Here is the code from the Widget service: what I see in the logs, is that the RequestUpdate gets called, but B4XPages is not available, thus skipping widget update
B4X:
Sub rv_RequestUpdate
WriteLog("updating")
If (B4XPages.IsInitialized) Then
If (B4XPages.MainPage.IsInitialized) Then
If (B4XPages.MainPage.DownloadNeeded) Then
WriteLog("data download needed")
Wait For (B4XPages.MainPage.DownloadData) Complete (success As Boolean)
WriteLog("data downloaded")
Else
WriteLog("data still fresh")
End If
B4XPages.MainPage.UpdateChartsForWidget 'updates bitmap in Starter service
rv.SetImage("IV_widgettrend1", Starter.bitmapwidget)
rv.UpdateWidget
Else
WriteLog("Mainpage not available")
End If
Else
WriteLog("B4XPages not available")
End If
End Sub