Android Question how to reduce batterie drain in case of service running full time?

candide

Active Member
Licensed User
hi
in first i have to explain context:
From several months i was looking for a simple way to alert family in case of trouble of old peoples. At start i use SOS alert bracelet able to send 433mhz message when button is pressed. (cost 8€). I found a gateway 433mhz: SONOFF RF bridge (cost 10€). After installation of tasmota on this bridge, i am able to send MQTT messages to a MQTT broker (cloudMQTT.com, free until 5 connexions). At last i was looking at an application under android to receive MQTT messages and to highlight in case of alert message. Because i I found nothing able to do that on GooglePlay, i decided to try to do an apk with B4A
with B4A, i built an apk based on all examples available on this forum and at last it is working when apk is open, with apk in background, when datas are moving between 4G - WIFI, and when mobile is locked. To have service not killed, i have to remove in mobile batterie optimisation for this apk. But at last i am facing a major issue: service in charge of MQTT message is running full time and it is drainning 30% of global drain of mobile...
and i have a few questions:
- do we have a way to reduce this battery drain?
- can you check if my management of service is correct?
code is added below, to help at understanding

thanks for your help
 

Attachments

  • SOS Alert_2.zip
    117.7 KB · Views: 287

kisoft

Well-Known Member
Licensed User
Longtime User
I solved it so, the gsm modem on which the voice message is recorded (Voice Synthesizer).
when the user activates the wireless button to activate the alarm, the module calls the telephone number and transmits the message (voice).
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
What about using Firebase messaging - this will allow your app to sleep and when the FB message comes in, Android will wake the device and start your service?
 
Last edited:
Upvote 0

candide

Active Member
Licensed User
thanks for yours answers.

first i tested "stopservice" and "StartServiceAt" on my apk: it is efficent on battery drain but MQTT messages are lost when my service is sleeping => i cannot use MQTT for this monitoring. (without buffering somewhere)

after a look at firebase, we have everything on Android side to build something but on sonoff RF gateway we don't have soft with firebase interface....

i will continue to search a solution.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…