imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 13, 2014 #1 Hello, I wrote an app that send a notification if the result of a query is not null. How can I send this notification, even if the app is close and it isn't in the task manager?
Hello, I wrote an app that send a notification if the result of a query is not null. How can I send this notification, even if the app is close and it isn't in the task manager?
Straker Active Member Licensed User Longtime User Oct 13, 2014 #2 If the app is not running, the is no code to be executed, therefore is impossible to show a notification. BUT if you have a service, from the service you can fire a notification. A service is the normal place for a notification. For example in your phone you receive a notification when you receive an email when your email app is not running. There is a service which periodically check for new emails. See this Erel's tutorial http://www.b4x.com/android/forum/threads/7542/#content and have a look at the examples. Upvote 0
If the app is not running, the is no code to be executed, therefore is impossible to show a notification. BUT if you have a service, from the service you can fire a notification. A service is the normal place for a notification. For example in your phone you receive a notification when you receive an email when your email app is not running. There is a service which periodically check for new emails. See this Erel's tutorial http://www.b4x.com/android/forum/threads/7542/#content and have a look at the examples.
imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 13, 2014 #3 I have to use a Sticky Service? What I have to do, after setting the attribute #StartCommandReturnValue: android.app.Service.START_STICKY? Upvote 0
I have to use a Sticky Service? What I have to do, after setting the attribute #StartCommandReturnValue: android.app.Service.START_STICKY?
Straker Active Member Licensed User Longtime User Oct 13, 2014 #4 Just start with a normal service. When the normal service works, the you may decide if in your case is better a sticky or normal. Upvote 0
Just start with a normal service. When the normal service works, the you may decide if in your case is better a sticky or normal.
imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 13, 2014 #5 But I don't want to send a normal notification. I need to set the value of this, by the result of the query Upvote 0
But I don't want to send a normal notification. I need to set the value of this, by the result of the query
Straker Active Member Licensed User Longtime User Oct 13, 2014 #6 ...which is a normal notification. A message at the top of the phone with an icon, a title and a message. Or something better if you use some specialized library. Upvote 0
...which is a normal notification. A message at the top of the phone with an icon, a title and a message. Or something better if you use some specialized library.
imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 13, 2014 #7 Please, can you post some example code? Upvote 0
Straker Active Member Licensed User Longtime User Oct 13, 2014 #8 You can find a lot of examples. The Erel's examples I already mentioned in post #2 are very good. You can also see the example I made for services and sockets in http://www.b4x.com/android/forum/threads/45017/#content which is extensively commented out, most of all from programmers coming from vb6 Upvote 0
You can find a lot of examples. The Erel's examples I already mentioned in post #2 are very good. You can also see the example I made for services and sockets in http://www.b4x.com/android/forum/threads/45017/#content which is extensively commented out, most of all from programmers coming from vb6
imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 13, 2014 #9 In these example I can't find any reference to Sticky service Upvote 0
Straker Active Member Licensed User Longtime User Oct 13, 2014 #10 Why sticky? I mean, a service is a service. It can be standard, or StartForeground or Sticky but at the end they are the same. The differences are that a StartForeground services has an icon on the task bar (let's say is not invisible) and is good for services that performs long running operation (download a huge file for example). Sticky services are more persistent, normally the O.S. doesn't kill the sticky services and if it kills it, it will be recreated as soon as possible by the same o.s. So, back to you, if you really need/want a sticky service, see the Erel tutorial http://www.b4x.com/android/forum/threads/27065/#content Upvote 0
Why sticky? I mean, a service is a service. It can be standard, or StartForeground or Sticky but at the end they are the same. The differences are that a StartForeground services has an icon on the task bar (let's say is not invisible) and is good for services that performs long running operation (download a huge file for example). Sticky services are more persistent, normally the O.S. doesn't kill the sticky services and if it kills it, it will be recreated as soon as possible by the same o.s. So, back to you, if you really need/want a sticky service, see the Erel tutorial http://www.b4x.com/android/forum/threads/27065/#content
DonManfred Expert Licensed User Longtime User Oct 14, 2014 #11 imgsimonebiliato said: In these example I can't find any reference to Sticky service Click to expand... Have you ever tried to search the forum instead of assuming ALL your problems are handled in ONE example? Upvote 0
imgsimonebiliato said: In these example I can't find any reference to Sticky service Click to expand... Have you ever tried to search the forum instead of assuming ALL your problems are handled in ONE example?