Android Question Ruining in background

yaqoob

Active Member
Licensed User
Longtime User
Hi

I am using mqtt for messaging in my application. I have two versions B4A and B4i. The B4i version receives the messages even if the application is running in the background and no messages are lost. B4A only receives messages if the application is running and it is in focus. The messages are lost if the application put the background and running.
 

Ricky D

Well-Known Member
Licensed User
Longtime User
Use a service in b4a don't do it in Starter I think. You can tell the service to be sticky or set to foreground.
 
Upvote 0

yaqoob

Active Member
Licensed User
Longtime User


I am using the foreground services as below code, but the application loses messages during it is in the background.


Private Sub client_MessageArrived (Topic As String, Payload() As Byte)


If IsPaused(Chat)=True Then

snotif.Initialize
snotif.Icon = "logo.png"

snotif.Sound = False
snotif.Vibrate=False
snotif.OnGoingEvent=False
snotif.Notify(1)
Service.StartForeground(1,snotif)
snotif.AutoCancel = True
.....


....
 
Upvote 0
Top