Android Question How to show image on Notification from a Remote MySQL Database

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

I am here for some suggestions and ideas regarding displaying an Image on the Notification. I am trying to use the library NotificationBuilder.

I know how to display the image on Notification from File.DirAssets using the below given code. Instead of showing an image from the File.DirAssets, I need to display image downloaded from a Remote MySQL database. So when the Notification reaches the user it should download the image and then it should be displayed to the user.

The code inside the Sub fm_MessageArrived (Message As RemoteMessage) in the Service FireBaseMessaging

B4X:
Dim nb As NotificationBuilder
Dim StyleBigPic As NotificationBigPictureStyle

nb.Initialize
nb.SmallIcon = "icon"
nb.Ticker = cSubject
nb.ContentTitle = "Title"
nb.AutoCancel = True

Dim BigPicture As Bitmap
'Here is the issue.  I do not want to display an image from File.DirAssets
' How do I get an image from a REMOTE database ?
' I know the tablename, Image column name of the table
' I do not know how to get the image from remote DB and display it here
' before the notification is displayed to the user.
' The app should switch to some function/procedure and wait till the image is downloaded
' and once the image is downloaded and ready it should execute the below given codes
' For eg Some Function that returns the Bitmap
'  Dim MyBitMap as Bitmap
'  MyBitMap = SomeFunction(nImage_ID)
' My doubt is here. How do I pause the further execution of code, till I receive the Bitmap
BigPicture.Initialize(File.DirAssets,"header4.png")  

StyleBigPic.Initialize
StyleBigPic.BigContentTitle = "This is BigContent Title"
StyleBigPic.SummaryText = "This is BigContent Summary Text"
StyleBigPic.BigPicture = BigPicture
nb.SetStyle(StyleBigPic)  

nb.setActivity(NotificationWebView)
nb.Tag = cUrl
nb.setParentActivity(HomePage)

nb.Notify(nNotificationCount)

Instead of going thru all this trouble, will it be possible to display the image using a webview on the Custom Notification layout ?

Basically, I am stuck at how to pause the program execution till the image is downloaded. Should I use a service or a code module for that etc.

Any help/suggestions will be appreciated.

Regards

Anser
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
I was so dump while posting the question here.
Just need to restructure the code and then use a service is the answer I believe.
 
Upvote 0
Top