T taylorw Active Member Licensed User Aug 3, 2017 #1 Hi all,i need a help. My problem is when i clear the ram the service was stop. I already refer to this post: https://www.b4x.com/android/forum/t...-long-running-background-tasks.27065/#content And this is my sample project. Attachments Sample.zip Sample.zip 388.2 KB · Views: 381
Hi all,i need a help. My problem is when i clear the ram the service was stop. I already refer to this post: https://www.b4x.com/android/forum/t...-long-running-background-tasks.27065/#content And this is my sample project.
Erel B4X founder Staff member Licensed User Longtime User Aug 3, 2017 #2 You should use File - Export as zip when uploading to the forum. The task manager kills the process so the service stops. The only thing that you can do, which might help, is to periodically call StartServiceAt to cause the Notification service to start again. Upvote 0
You should use File - Export as zip when uploading to the forum. The task manager kills the process so the service stops. The only thing that you can do, which might help, is to periodically call StartServiceAt to cause the Notification service to start again.
T taylorw Active Member Licensed User Aug 3, 2017 #3 Erel this is my sample project. And can i do like this? Code: Copy Sub Service_Destroy StartServiceAt("",DateTime.Now + 10*10, True) End Sub Attachments Sample.zip Sample.zip 388.2 KB · Views: 484 Upvote 0
Erel this is my sample project. And can i do like this? Code: Copy Sub Service_Destroy StartServiceAt("",DateTime.Now + 10*10, True) End Sub
DonManfred Expert Licensed User Longtime User Aug 3, 2017 #4 taylorw said: And can i do like this? Click to expand... you´ll start it in 100ms again (0,1 SECOND)????? Upvote 0
taylorw said: And can i do like this? Click to expand... you´ll start it in 100ms again (0,1 SECOND)?????
T taylorw Active Member Licensed User Aug 3, 2017 #5 Sorry, that is my mistake. Now i change like this. Code: Copy Sub Service_Destroy StartServiceAt("",DateTime.Now + 10 * 1000, True) End Sub But when i lock screen it will be kill again. Upvote 0
Sorry, that is my mistake. Now i change like this. Code: Copy Sub Service_Destroy StartServiceAt("",DateTime.Now + 10 * 1000, True) End Sub But when i lock screen it will be kill again.
Star-Dust Expert Licensed User Longtime User Aug 3, 2017 #6 I did several attempts. I tried the code on different devices, android 4, 4.20, 5, 5.1 and 6 This anomaly occurs only on Huawei with Android 6.0 So I suppose either the version of Android or the Huawei firmware is the same as Honor StartServiceAt is good solution Last edited: Aug 3, 2017 Upvote 0
I did several attempts. I tried the code on different devices, android 4, 4.20, 5, 5.1 and 6 This anomaly occurs only on Huawei with Android 6.0 So I suppose either the version of Android or the Huawei firmware is the same as Honor StartServiceAt is good solution
KMatle Expert Licensed User Longtime User Aug 3, 2017 #7 Search for “Huawei + Protected Apps“ (or on your phone under settings - energy savings Upvote 0
T taylorw Active Member Licensed User Aug 4, 2017 #8 Thank you very much. Really thanks for your time. Best regards. Upvote 0
Star-Dust Expert Licensed User Longtime User Aug 4, 2017 #9 I tried on an Asus ZenFone 2 with Android 6.01 and it works correctly. The operating system kills the app but the service stays sticky, so it works properly. Upvote 0
I tried on an Asus ZenFone 2 with Android 6.01 and it works correctly. The operating system kills the app but the service stays sticky, so it works properly.
Alpandino Member Licensed User Aug 8, 2017 #10 Erel said: You should use File - Export as zip when uploading to the forum. The task manager kills the process so the service stops. The only thing that you can do, which might help, is to periodically call StartServiceAt to cause the Notification service to start again. Click to expand... Sorry, why I'd call StartServiceAt instead of making my service a "sticky" service? Making a service "sticky" using #StartCommandReturnValue: android.app.Service.START_STICKY should restart my service if someone will kill it, right? Upvote 0
Erel said: You should use File - Export as zip when uploading to the forum. The task manager kills the process so the service stops. The only thing that you can do, which might help, is to periodically call StartServiceAt to cause the Notification service to start again. Click to expand... Sorry, why I'd call StartServiceAt instead of making my service a "sticky" service? Making a service "sticky" using #StartCommandReturnValue: android.app.Service.START_STICKY should restart my service if someone will kill it, right?
Erel B4X founder Staff member Licensed User Longtime User Aug 8, 2017 #11 It is not instead of a sticky service. You can make the service both sticky and use StartServiceAt to ask the OS to start it from time to time. Background processes are becoming more and more restricted in newer versions of Android. Upvote 0
It is not instead of a sticky service. You can make the service both sticky and use StartServiceAt to ask the OS to start it from time to time. Background processes are becoming more and more restricted in newer versions of Android.
Alpandino Member Licensed User Aug 8, 2017 #12 Erel said: It is not instead of a sticky service. You can make the service both sticky and use StartServiceAt to ask the OS to start it from time to time. Background processes are becoming more and more restricted in newer versions of Android. Click to expand... But I have read that a service should restart if someone will kill it, right? Upvote 0
Erel said: It is not instead of a sticky service. You can make the service both sticky and use StartServiceAt to ask the OS to start it from time to time. Background processes are becoming more and more restricted in newer versions of Android. Click to expand... But I have read that a service should restart if someone will kill it, right?
Erel B4X founder Staff member Licensed User Longtime User Aug 9, 2017 #13 Theoretically yes. Practically it will not always work. Upvote 0