I have read many times that the best example on how to create a "stable" foreground service is MyLocation, so I tried it.
It works but I am trying to get the same behavoir of some other famous apps, like Whatsapp, Twitter, Zynga Poker, etc.
They are able to receive notifications (obviously from their servers) without there being a first notification fixed on the relative bar, unlike what happens with MyLocation.
I got this by modifying this line:
this way:
This works but then the service will have many problems, it will be destroyed very soon and, when automatically restarted, it will be immediately killed again, until the moment when it does not restart at all.
I'm attaching the slightly modified version of MyLocation:
1) it uses a timer because here, indoors, the gps event never fires;
2) many logs added;
3) the line decribed above.
Is there any way to get the same behavior as those apps?
[I hope you won't recommend FCM to me; also because it will work somehow too, won't it?]
It works but I am trying to get the same behavoir of some other famous apps, like Whatsapp, Twitter, Zynga Poker, etc.
They are able to receive notifications (obviously from their servers) without there being a first notification fixed on the relative bar, unlike what happens with MyLocation.
I got this by modifying this line:
B4X:
Service.StartForeground(nid, CreateNotification("..."))
this way:
B4X:
Service.StartForeground(0, Null)
This works but then the service will have many problems, it will be destroyed very soon and, when automatically restarted, it will be immediately killed again, until the moment when it does not restart at all.
I'm attaching the slightly modified version of MyLocation:
1) it uses a timer because here, indoors, the gps event never fires;
2) many logs added;
3) the line decribed above.
Is there any way to get the same behavior as those apps?
[I hope you won't recommend FCM to me; also because it will work somehow too, won't it?]
Attachments
Last edited: