The thread title is a bit undescriptive because I could not come up with the right words.
So my app runs a service to deal with bluetooth comms, it's quite a complex serive but works well. However, leave my app and open SETTINGS->BLUETOOTH, this new settings activity automatically starts a bluetooth scan, which means that the DeviceFound function in my service module gets hit when a device is found. Since the scan was not started from my service, this creates problems.
Similarly, if I turn bluetooth off in SETTINGS->BLUETOOTH or by any other means, Serial1_Connected in my service module gets hit unexpectedly and that causes problems.
I am just trying to figure out what the best way to deal with this might be:
1: Kill the service when my app goes in the background (I think I read that this is discouraged)
2: Somehow detect if my app is in the background when these functions are hit, and exit the functions without doing anything if this is the case. How could I detect that though?
3: Something else
Thanks
So my app runs a service to deal with bluetooth comms, it's quite a complex serive but works well. However, leave my app and open SETTINGS->BLUETOOTH, this new settings activity automatically starts a bluetooth scan, which means that the DeviceFound function in my service module gets hit when a device is found. Since the scan was not started from my service, this creates problems.
Similarly, if I turn bluetooth off in SETTINGS->BLUETOOTH or by any other means, Serial1_Connected in my service module gets hit unexpectedly and that causes problems.
I am just trying to figure out what the best way to deal with this might be:
1: Kill the service when my app goes in the background (I think I read that this is discouraged)
2: Somehow detect if my app is in the background when these functions are hit, and exit the functions without doing anything if this is the case. How could I detect that though?
3: Something else
Thanks