marcick Well-Known Member Licensed User Longtime User Sep 27, 2016 #1 I have some initializations in Starter Service and I want to be sure everything is starting from scratch when the app is launched after it has been closed with the back button. So I have this code Code: Copy Sub Activity_Pause (UserClosed As Boolean) If UserClosed=True Then StopService ("Starter") End Sub Closing the App with the Back Button I see in the Log that the Starter Service is destroyed, but launching the App again It is not recreated and restarted. Where I'm wrong ?
I have some initializations in Starter Service and I want to be sure everything is starting from scratch when the app is launched after it has been closed with the back button. So I have this code Code: Copy Sub Activity_Pause (UserClosed As Boolean) If UserClosed=True Then StopService ("Starter") End Sub Closing the App with the Back Button I see in the Log that the Starter Service is destroyed, but launching the App again It is not recreated and restarted. Where I'm wrong ?
DonManfred Expert Licensed User Longtime User Sep 27, 2016 #2 You should not stop (or start) the starter service by yourself Upvote 0
marcick Well-Known Member Licensed User Longtime User Sep 27, 2016 #3 I know I shouldn't but it's better for me that the code in the Starter Service is executed everytime the App is launched. And the App has several possible entry point. Upvote 0
I know I shouldn't but it's better for me that the code in the Starter Service is executed everytime the App is launched. And the App has several possible entry point.
Erel B4X founder Staff member Licensed User Longtime User Sep 27, 2016 #4 marcick said: I know I shouldn't but it's better for me that the code in the Starter Service is executed everytime the App is launched. And the App has several possible entry point. Click to expand... This is exactly the purpose of the Starter service. You don't need to stop it yourself. Pressing on the back key doesn't kill the process. The process global variables will be kept alive until the process is killed. Upvote 0
marcick said: I know I shouldn't but it's better for me that the code in the Starter Service is executed everytime the App is launched. And the App has several possible entry point. Click to expand... This is exactly the purpose of the Starter service. You don't need to stop it yourself. Pressing on the back key doesn't kill the process. The process global variables will be kept alive until the process is killed.
marcick Well-Known Member Licensed User Longtime User Sep 27, 2016 #5 I understand but: I have for example to check if a db exists and if not create it. The App has multiple entry point so I have put that check in the starter service and it works ok. Suppose now the db is deleted form outside. If I close and restart the App the starter service is not started again until I reboot the device. So my App crash here and there when it tries to access to the db. Do I have to repeat that check (db exists) for every possible App entry point or there is a way to execute starter service every time the App is launched ? Upvote 0
I understand but: I have for example to check if a db exists and if not create it. The App has multiple entry point so I have put that check in the starter service and it works ok. Suppose now the db is deleted form outside. If I close and restart the App the starter service is not started again until I reboot the device. So my App crash here and there when it tries to access to the db. Do I have to repeat that check (db exists) for every possible App entry point or there is a way to execute starter service every time the App is launched ?
Erel B4X founder Staff member Licensed User Longtime User Sep 27, 2016 #6 marcick said: If I close and restart the App the starter service is not started again until I reboot the device. Click to expand... Not exactly. Android will kill the process when it is in the background. Why will the database be deleted? If you think that it is possible then store it in File.DirInternal. Upvote 0
marcick said: If I close and restart the App the starter service is not started again until I reboot the device. Click to expand... Not exactly. Android will kill the process when it is in the background. Why will the database be deleted? If you think that it is possible then store it in File.DirInternal.
marcick Well-Known Member Licensed User Longtime User Sep 27, 2016 #7 Ok, understand how it works. StopService(Starter) stop the service but not in a way it is started again when you restart the App (maybe after some time but not immediately). Need to do some modifications. Thanks Upvote 0
Ok, understand how it works. StopService(Starter) stop the service but not in a way it is started again when you restart the App (maybe after some time but not immediately). Need to do some modifications. Thanks