I am trying to create a fitness app that will monitor the steps that i take. Ive been testing for almost 7 days now, and im really struggling to achieve this.
So far i managed to create code that run when the screen is on, but it will stop running after the screen is turned off after 1-3 minutes. My code simply saves a word every 1 min, or 10 secs or 1 sec, i tested with all 3 configurations.
I tried using the following:
- AlartManager (all of the difference alarms)
- WakefulBroadcastReceiver
- Broadcastreceiver
- Service (StartForeground)
- Wake Locks
- To add my app to the whitelist so that "Doze mode" on the Samsung device wont intefear.
- To totally remove the app from the battery optimization
I got over 10 different examples on my PC, all of them preform as described. So i will try a different approach and ask a simple straight out question.
Testing devices
HTC M8 one Android v6.0.1
Samsung Galaxy s6 edge Android v6.0.1
Question
All i want is code that can run when the screen is black, also after 30 mins and more. Not just 1-3 minutes. It seems to be more challenging than balancing on 1 finger :-)
Can anyone help me with some code so that i can go in the right directions?
Sorry for not posting real code in this question, i felt it was not appropriate since i tried so many things, that this post would be 67 scrolls long :-)
Prior questions
If you want to see some off the code i created before in order to acvieve what i want here is a post. Android OS shuts down the Wakelock + AlarmManager after a few minutes