在我的 android 应用程序中,用户可以使用他的 android 手机通过另一台设备的蓝牙进行固件更新。
我的问题是:是否可以检测到用户何时尝试关闭蓝牙并向他发送一条警告消息,例如:“警告关闭蓝牙将中断固件更新!”
使用 BluetoothAdapter 广播操作:
public static final String ACTION_STATE_CHANGED
Since: API Level 5 Broadcast Action: The state of the local Bluetooth adapter has been changed. For example, Bluetooth has been turned on or off. Always contains the extra fields EXTRA_STATE and EXTRA_PREVIOUS_STATE containing the new and old states respectively. Requires BLUETOOTH to receive.
Constant Value: "android.bluetooth.adapter.action.STATE_CHANGED"
只有蓝牙已经关闭后才能接收广播(所以警告为时已晚^^)
任何帮助将不胜感激! 最好的问候
最佳答案
您应该在固件更新开始时显示此类关键消息。之后,如果用户关闭蓝牙,则由他负责。他不能将任何损失归咎于您的软件。
而且我认为我们不被允许阻止诸如关闭蓝牙之类的操作。允许此类阻止将使其容易受到黑客攻击。恶意应用可能会阻止用户关闭蓝牙。
关于android - 是否可以检测到用户将关闭Android上的蓝牙?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7398331/