Share My Creation B4A Quotes Widget - in B4XPages

I am very very happy today.
I have been able to complete the app I was trying for last few months.

My goal was to,
make a widget app
make it in B4XPages
it would download html from url
parse the html and extract text
show the text in the widget
would run every hour or so

I have achieved in all my goals, thanks to B4X.

Taking cue from Saif, I start by thanking @Erel.

Not only because Erel made B4X but also it is Erel's widget sample code which I took as inspiration.
It is a Quotes Widget, very old and uses old libraries which give errors now, as discussed here,

Below are the screen-shots of my "B4A Quotes Widget" app.

p4.pngp2.png p3.png p1.png

In main screen you enter the url (taken one from original sample of Erel). Check it with 'Load Quote' button. 'Save & Close' the app.
In widget touch the 'play' button and it will load quote from the url and display. There are 4 quotes and widget displays them one after another.
Widget will auto load quote every hour.
A clock is also running to show that the widget is active. May be it will stop in higher Android version.
Widget need internet connection and will show failed if not found.

I have checked it in Android 5 Lenevo only but would like feedback in Android 10+, if any member have one.

I have attached the project source codes and request members to play with it. If one can enhance it, upload the code here for benefit of other members.

I have plan to add radio buttons for urls as given in original sample of Erel, to select. So that user can just select the one required. Also to have touch event in widget to open the main activity.



version 2 : manifest correction for Android 10+ on 06 May 2021
version 1 : initial release on 06 May 2021


    359.4 KB · Views: 348
Last edited:


Licensed User
Hi Anand:

Thanks for sharing.
Testing on a Samsung A10 with Android 10.
I get the CLEARTEXT error. (The second part of the error is due running the app in debug mode, widgets app must be tested in RELEASE mode)

So, you have to add to your project's manifest:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)
As noted in the android.jar / targetSdkVersion / minSdkVersion tutorial, and then it works great¡¡

Error logs:
Registro conectado a:  samsung SM-A105FN
--------- beginning of main
Copying updated assets files (6)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: CLEARTEXT communication to not permitted by network security policy, Response:
** Activity (main) Pause event (activity is not paused). **
** Receiver (widgetservice) OnReceive **
*** Service (widgetservice) Create ***
Error occurred on line: 23 (WidgetService) l1.bal
    at android.content.res.AssetManager.nativeOpenAsset(Native Method)
    at anywheresoftware.b4a.objects.RemoteViewsWrapper.createRemoteViews(
    at b4a.quotes_widget.widgetservice._service_create(
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(
    at anywheresoftware.b4a.BA.raiseEvent(
    at b4a.quotes_widget.widgetservice.onCreate(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
** Service (widgetservice) Start **


Licensed User
Longtime User
Testing on a Samsung A10 with Android 10.
Thanks a lot Jose for testing the codes.

I have added in manifest as advised now. Yes I created and tested in release mode only, but in Android 5.

I have updated project zip in 1st post.