Android Question timer not raised early morning, but wakeup ok

pesquera

Active Member
Licensed User
Longtime User
Hi everyone,

On a Service_Start I call a routine that initiates a timer for 1 minute
The routine for the timer tick is called fine until late night

But, at early morning.. I noticed that the timer is not raised until I do some activity on my phone.. like shut the alarm off or something else
In other word.. when I wake up the phone, the timer is working again

Should I take care about something to support "long" sleep phone?

B4X v8.00, Android 8.1.0

Thanks in advance
 

pesquera

Active Member
Licensed User
Longtime User
and acquire a partial lock with PhoneWakeState
I had it in foreground mode, the solution was the partial lock.. thanks a lot!

another question, just in case.. I never release it, could it be a problem? (battery drain, cpu usage, etc.)
 
Upvote 0

pesquera

Active Member
Licensed User
Longtime User
You need to release it when the task is complete

I need the timer every 1 minute all day to check if must send a remainder via SMS
Where do you suggest to release it?
I'm a bit confused about when the task is completed (I think that never is completed)
 
Upvote 0

udg

Expert
Licensed User
Longtime User
If you have a list of already set remainders you could start the service at their set time instead of checking each minute.
If during the day your user set a new remainder, you update the list, check which is the next wake up time and set accordingly the service to start (StartAt or StartExactAt or something like that; sorry, I'm not a my PC now so can't check the right method name).
 
Upvote 0

pesquera

Active Member
Licensed User
Longtime User
thanks @udg so much
I can see on the help that StartAt/StartExactAct could also impact on the battery (never used them).. do you think that anyway is better than never release the partial lock?

EDIT: let's say that tonight 7.00 pm checking the next remainder is tomorrow morning at 7.00 am
 
Last edited:
Upvote 0

udg

Expert
Licensed User
Longtime User
do you think that anyway is better than never release the partial lock?
IMHO, definitely yes.
The scheme could go like this:
- in remainder service Start (please, not Starter service) you set next wake up time
- you check whether the intent that woke up your service is the "right one" (i.e. If StartingIntent.HasExtra("android.intent.extra.ALARM_COUNT") Then...) and in that case prepare a Notification.
- The user will open your Notification and will be directed to the activity serving your reminder
- or you acquire a lock, do whatever is needed and release the lock

If I recall it correctly, there should be an example from Erel showing a very similar process (a list of times and a FindeNextTime function).
 
Upvote 0

Similar Threads

Top