M Mike1970 Well-Known Member Licensed User Longtime User Oct 20, 2019 #1 Hi everyone, i'm taking a look to @Erel example on Geofence (https://www.b4x.com/android/forum/t...ing-a-region-in-the-background.84767/#content). I'm trying to change it in order to implement it as foreground service, in this way TEORICALLY the OS can't kill my process (after months i didn't achieve this result yet). The problem is that i scheduled the geofencing service to start every 5 minutes and automaticforeground stops after he return a result, BUT this work only the first time, the second time it doens't respond. I put this in Service_Create Code: lock.PartialLock Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER This in Service_Start Code: Service.StartForeground(1, CreateNotification("Controllo...")) StartServiceAtExact(Me, DateTime.Now + Freq*DateTime.TicksPerMinute, True) + the CreateNotification Sub This at the end of the Service_Start Code: Service.StopAutomaticForeground And this in Service_Destroy Code: lock.ReleasePartialLock The rest is the same as in the example linked before. What's wrong? I leave the project in the attached file. Thank in advance Attachments Geofence_Foreground_Test.zip Geofence_Foreground_Test.zip 8.9 KB · Views: 574 Last edited: Oct 20, 2019
Hi everyone, i'm taking a look to @Erel example on Geofence (https://www.b4x.com/android/forum/t...ing-a-region-in-the-background.84767/#content). I'm trying to change it in order to implement it as foreground service, in this way TEORICALLY the OS can't kill my process (after months i didn't achieve this result yet). The problem is that i scheduled the geofencing service to start every 5 minutes and automaticforeground stops after he return a result, BUT this work only the first time, the second time it doens't respond. I put this in Service_Create Code: lock.PartialLock Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER This in Service_Start Code: Service.StartForeground(1, CreateNotification("Controllo...")) StartServiceAtExact(Me, DateTime.Now + Freq*DateTime.TicksPerMinute, True) + the CreateNotification Sub This at the end of the Service_Start Code: Service.StopAutomaticForeground And this in Service_Destroy Code: lock.ReleasePartialLock The rest is the same as in the example linked before. What's wrong? I leave the project in the attached file. Thank in advance
DonManfred Expert Licensed User Longtime User Oct 20, 2019 #2 Mike1970 said: The problem is that i scheduled the geofencing service to start every 5 minutes Click to expand... You got told (multiple times) that you are not allowed to restart a service in this interval! Android (at least higher SDKs) does NOT allow it. Why you are still trying it? Upvote 0
Mike1970 said: The problem is that i scheduled the geofencing service to start every 5 minutes Click to expand... You got told (multiple times) that you are not allowed to restart a service in this interval! Android (at least higher SDKs) does NOT allow it. Why you are still trying it?
M Mike1970 Well-Known Member Licensed User Longtime User Oct 20, 2019 #3 DonManfred said: You got told (multiple times) that you are not allowed to restart a service in this interval! Android (at least higher SDKs) does NOT allow it. Why you are still trying it? Click to expand... Because even if i restart every 30 MINUTES it doesn’t work! I already told ! Ok? In the GPS post someone said that to him checking every 30 minutes worked for 6 days and more, to me less than 11 Hours... It is obvious that there is something else to be spotted, do you agree?? Last edited: Oct 20, 2019 Upvote 0
DonManfred said: You got told (multiple times) that you are not allowed to restart a service in this interval! Android (at least higher SDKs) does NOT allow it. Why you are still trying it? Click to expand... Because even if i restart every 30 MINUTES it doesn’t work! I already told ! Ok? In the GPS post someone said that to him checking every 30 minutes worked for 6 days and more, to me less than 11 Hours... It is obvious that there is something else to be spotted, do you agree??
Erel B4X founder Staff member Licensed User Longtime User Oct 21, 2019 #4 1. Calling StartServiceAt with an interval less than 30 minutes will not work. 2. You are making duplicate posts, which is very bad. The answer was given here: https://www.b4x.com/android/forum/t...ground-gps-tracking.110628/page-2#post-690743 Upvote 0
1. Calling StartServiceAt with an interval less than 30 minutes will not work. 2. You are making duplicate posts, which is very bad. The answer was given here: https://www.b4x.com/android/forum/t...ground-gps-tracking.110628/page-2#post-690743
M Mike1970 Well-Known Member Licensed User Longtime User Oct 21, 2019 #5 Erel said: 1. Calling StartServiceAt with an interval less than 30 minutes will not work. 2. You are making duplicate posts, which is very bad. The answer was given here: https://www.b4x.com/android/forum/t...ground-gps-tracking.110628/page-2#post-690743 Click to expand... 1. Ok thanks, (even if I already tried, don't mind) 2. Sorry, I thought that given it was a different "tool" (pure GPS vs GeoFence) I had to write another post. Upvote 0
Erel said: 1. Calling StartServiceAt with an interval less than 30 minutes will not work. 2. You are making duplicate posts, which is very bad. The answer was given here: https://www.b4x.com/android/forum/t...ground-gps-tracking.110628/page-2#post-690743 Click to expand... 1. Ok thanks, (even if I already tried, don't mind) 2. Sorry, I thought that given it was a different "tool" (pure GPS vs GeoFence) I had to write another post.