1

I am currently using a foreground service to check every 30 seconds if a specific bluetooth device is in range.

When it comes in range I connect to it and read data to display to the user.

I've been reading up on background services, and even though during the actual connection it should be a foreground service, while waiting to connect it should be a background one.

so I made a different service (yes I know I could just move it into foreground when it becomes connected, but I prefer to use a different service for it) which is in the background and will continuously scan for the specific mac address, when it finds it it will start the working service which will run in the background.

I don't mind the system killing my service if it is low on memory (it is not that important, plus if the user wishes to connect they can force the connection through the ui which will start the foreground service), but I would like to make sure that when there is enough memory the service is started again, is START_STICKY enough?

In case the system destroys my service, where do I put the clean up code? will onDestroy always fire?

Finally how can I test low memory conditions for android so as to make sure the restart goes correctly?

this has been answered here please ignore it

Cruces
  • 3,029
  • 1
  • 26
  • 55
  • 1
    i think overall your question is pretty interesting, but `Finally how can I test low memory conditions` has probably been asked previously or you could perhaps find resources available for this online already, not saying you should remove it from your post but you might find available info on this already – a_local_nobody Feb 16 '22 at 11:24
  • you're right, I found it with a quick google search, I mainly wanted to ask the first part, but I figured I should ask more, I'll update my question, thanks – Cruces Feb 16 '22 at 11:25
  • 1
    makes no difference to me whether or not you leave it in, some people might want to hit you with the "needs more focus" hammer if you do decide to leave it in though :) – a_local_nobody Feb 16 '22 at 11:27
  • yeah I know, I've had a number of questions marked as duplicate because one of my X questions was already answered, I updated my question to show where people can go to get the answer if they have the same question :) – Cruces Feb 16 '22 at 11:28

0 Answers0