Hi,
I am using the BleExtended Library and I am able to scan and connect to a Bluetooth device and get it's services etc.
When I get the service from the device I am then sending a SMS message.
All this is working and I am doing this from a service within my app so it can do this in the background while the app is not showing on the screen.
The problem I have now is that Android 6.0 has added a new feature called Doze. Doze will stop my app from running in the background while the screen is off and while the device it not moving.
http://developer.android.com/training/monitoring-device-state/doze-standby.html
However, I noticed there is a way to allow the app in a whitelist:
Would I be correct in saying that the above will allow the app to run in the background by enabling this feature?
If so, how can I do the following in my app so it prompts the user when they run the app ?
I am using the BleExtended Library and I am able to scan and connect to a Bluetooth device and get it's services etc.
When I get the service from the device I am then sending a SMS message.
All this is working and I am doing this from a service within my app so it can do this in the background while the app is not showing on the screen.
The problem I have now is that Android 6.0 has added a new feature called Doze. Doze will stop my app from running in the background while the screen is off and while the device it not moving.
Starting from Android 6.0 (API level 23), Android introduces two power-saving features that extend battery life for users by managing how apps behave when a device is not connected to a power source. Doze reduces battery consumption by deferring background CPU and network activity for apps when the device is unused for long periods of time. App Standby defers background network activity for apps with which the user has not recently interacted.
http://developer.android.com/training/monitoring-device-state/doze-standby.html
However, I noticed there is a way to allow the app in a whitelist:
Users can manually configure the whitelist in Settings > Battery > Battery Optimization. Alternatively, the system provides ways for apps to ask users to whitelist them.
Would I be correct in saying that the above will allow the app to run in the background by enabling this feature?
If so, how can I do the following in my app so it prompts the user when they run the app ?
An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can trigger a system dialog to let the user add the app to the whitelist directly, without going to settings. The app fires a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the dialog.