Android Question Help me with a Battery notification app

laviniut

Active Member
Licensed User
Longtime User
Please help me to make a working Battery notification app.
I made one that working in android 7 and less with B4A less than v8.
The app use a widget service in foreground and for that a notification appear at boot, but starting the application, notification gone.
Here is the link with old version app:
https://play.google.com/store/apps/details?id=ombun.batterymonitor.com

Now i need to make the app for sdk 26 and with B4A 8+ but i have problems. I test a lot of variants but i cannot get a service to start at boot and working in background to monitor battery level.
I attached the app to which I work now.
Please help me.
 

Attachments

  • battery notification5.zip
    90.8 KB · Views: 301

Erel

B4X founder
Staff member
Licensed User
Longtime User
I test a lot of variants but i cannot get a service to start at boot and working in background
Just add this line to your service in Service_Create:
B4X:
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS

Make sure NOT to use the starter service for this.
 
Upvote 0

laviniut

Active Member
Licensed User
Longtime User
If i use this:
B4X:
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
or
B4X:
#StartCommandReturnValue: android.app.Service.START_STICKY
then service is running and start at boot, but allways i have a notification in notification bar.
Can i skip this notification?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top