M madSac Active Member Licensed User Longtime User Mar 11, 2013 #1 I have nearly completed my application but I am still facing an issue. I have a service which always runs in background, searching much in forum I used method startserviceat(). But I am not satisfied. I tried using method startforeground with a notification icon but it was always cleared out whenever I cleaned using estaskmanager. I compared my service with whatsapp, it was never terminated except when I killed it manually...and there service uptime was much greater than mine even I started my service with whatsapp. So can anyone provide a better solution I would really appreciate. I just want to make a service always alive just like whatsapp messaging service.
I have nearly completed my application but I am still facing an issue. I have a service which always runs in background, searching much in forum I used method startserviceat(). But I am not satisfied. I tried using method startforeground with a notification icon but it was always cleared out whenever I cleaned using estaskmanager. I compared my service with whatsapp, it was never terminated except when I killed it manually...and there service uptime was much greater than mine even I started my service with whatsapp. So can anyone provide a better solution I would really appreciate. I just want to make a service always alive just like whatsapp messaging service.
Erel B4X founder Staff member Licensed User Longtime User Mar 11, 2013 #2 Based on this thread: android - how does whatsapp service gets restarted even if i force stop app? - Stack Overflow Whatsapp uses the standard push framework to receive messages. There are other workarounds (which are not 100% reliable). You can create a static intent filter that listens to a relatively common message. This will allow you to restart your process if it was killed by a task manager. It is not possible to create a process that cannot be killed by a task manager. Upvote 0
Based on this thread: android - how does whatsapp service gets restarted even if i force stop app? - Stack Overflow Whatsapp uses the standard push framework to receive messages. There are other workarounds (which are not 100% reliable). You can create a static intent filter that listens to a relatively common message. This will allow you to restart your process if it was killed by a task manager. It is not possible to create a process that cannot be killed by a task manager.
M madSac Active Member Licensed User Longtime User Mar 12, 2013 #3 Erel said: Based on this thread: android - how does whatsapp service gets restarted even if i force stop app? - Stack Overflow Whatsapp uses the standard push framework to receive messages. There are other workarounds (which are not 100% reliable). You can create a static intent filter that listens to a relatively common message. This will allow you to restart your process if it was killed by a task manager. It is not possible to create a process that cannot be killed by a task manager. Click to expand... ok I understood I will find a way using intent. The main problem that startserviceat method is not reliable as when I started thread the service was running and now its terminated. Can you tell why process is terminated even if I use startforeground ? I tried your sample and it was terminated where as other similar services were not terminated like uc download manager. Upvote 0
Erel said: Based on this thread: android - how does whatsapp service gets restarted even if i force stop app? - Stack Overflow Whatsapp uses the standard push framework to receive messages. There are other workarounds (which are not 100% reliable). You can create a static intent filter that listens to a relatively common message. This will allow you to restart your process if it was killed by a task manager. It is not possible to create a process that cannot be killed by a task manager. Click to expand... ok I understood I will find a way using intent. The main problem that startserviceat method is not reliable as when I started thread the service was running and now its terminated. Can you tell why process is terminated even if I use startforeground ? I tried your sample and it was terminated where as other similar services were not terminated like uc download manager.
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2013 #4 The StartForeground notification icon has disappeared? Upvote 0
M madSac Active Member Licensed User Longtime User Mar 12, 2013 #5 Erel said: The StartForeground notification icon has disappeared? Click to expand... Yes and service terminated.I have tried nearly all codes even your twitter sample is terminating. Upvote 0
Erel said: The StartForeground notification icon has disappeared? Click to expand... Yes and service terminated.I have tried nearly all codes even your twitter sample is terminating.
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2013 #6 Whether the service is kept running or not depends on the task manager. Service.StartForeground is a standard Android API. You can search Google. You will see that there are many similar discussions about task managers and services. There is no simple way to keep a service running if the user is using a task manager. Upvote 0
Whether the service is kept running or not depends on the task manager. Service.StartForeground is a standard Android API. You can search Google. You will see that there are many similar discussions about task managers and services. There is no simple way to keep a service running if the user is using a task manager.
M madSac Active Member Licensed User Longtime User Mar 12, 2013 #7 Erel said: Whether the service is kept running or not depends on the task manager. Service.StartForeground is a standard Android API. You can search Google. You will see that there are many similar discussions about task managers and services. There is no simple way to keep a service running if the user is using a task manager. Click to expand... I haven't killed a process individually I just used optimizer option which kills all processes.My service was killed but whatsapp and ucdownload services we're running uninterrupted I just want to achieve that. Take a look Android Service Tutorial Upvote 0
Erel said: Whether the service is kept running or not depends on the task manager. Service.StartForeground is a standard Android API. You can search Google. You will see that there are many similar discussions about task managers and services. There is no simple way to keep a service running if the user is using a task manager. Click to expand... I haven't killed a process individually I just used optimizer option which kills all processes.My service was killed but whatsapp and ucdownload services we're running uninterrupted I just want to achieve that. Take a look Android Service Tutorial
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2013 #8 See a similar discussion here: Killing android application from task manager kills services started by app - Stack Overflow Running a service in its own process can help but is much more complicated. You can achieve a similar result by creating another application that is only responsible for the download. Upvote 0
See a similar discussion here: Killing android application from task manager kills services started by app - Stack Overflow Running a service in its own process can help but is much more complicated. You can achieve a similar result by creating another application that is only responsible for the download.
M madSac Active Member Licensed User Longtime User Mar 13, 2013 #9 I not only want to download....but I want to run a service which always runs....it also listens to c2dm Upvote 0
I not only want to download....but I want to run a service which always runs....it also listens to c2dm
Erel B4X founder Staff member Licensed User Longtime User Mar 13, 2013 #10 Read the tutorial about intent filters. Upvote 0
Q qnw4ts7pge Member Licensed User Longtime User Jun 5, 2013 #11 So here is my solution... I have a service that I restart in Service_Start with StartServiceAt......now+10000 (every 10 seconds) I don't know if there are any drawbacks yet. I have ONE feature that I don't want to persist across reboots. When rebooted, it should default to "off", but I don't have any way to tell if the Service_Create was invoked by a boot, or a StartServiceAt? Is there an UpTime function or similar? Upvote 0
So here is my solution... I have a service that I restart in Service_Start with StartServiceAt......now+10000 (every 10 seconds) I don't know if there are any drawbacks yet. I have ONE feature that I don't want to persist across reboots. When rebooted, it should default to "off", but I don't have any way to tell if the Service_Create was invoked by a boot, or a StartServiceAt? Is there an UpTime function or similar?
warwound Expert Licensed User Longtime User Jun 5, 2013 #12 You can detect if the service was (auto) started at boot using this code: Code: Copy Sub Service_Start (StartingIntent As Intent) If StartingIntent.Action="android.intent.action.BOOT_COMPLETED" Then ' service was auto started at boot Else ' service was not auto started at boot End If End Sub Martin. Upvote 0
You can detect if the service was (auto) started at boot using this code: Code: Copy Sub Service_Start (StartingIntent As Intent) If StartingIntent.Action="android.intent.action.BOOT_COMPLETED" Then ' service was auto started at boot Else ' service was not auto started at boot End If End Sub Martin.
M madSac Active Member Licensed User Longtime User Jun 6, 2013 #13 qnw4ts7pge said: Is there an UpTime function or similar? Click to expand... This gives you uptime of your application & shows the drawback of startserviceat....sometimes you will get uptime very low as application is closed & started again..variables are reseted ! Code: Copy Dim os As OperatingSystem log(os.ElaspedCPUTime) Upvote 0
qnw4ts7pge said: Is there an UpTime function or similar? Click to expand... This gives you uptime of your application & shows the drawback of startserviceat....sometimes you will get uptime very low as application is closed & started again..variables are reseted ! Code: Copy Dim os As OperatingSystem log(os.ElaspedCPUTime)