我有一个服务,我创建了一个 AcceptThread(如 http://developer.android.com/guide/topics/wireless/bluetooth.html)来接受传入的蓝牙连接。 当设备进入待机状态时它会工作吗?
最佳答案
我在服务中使用线程,虽然我没有使用过蓝牙,但我认为这可以帮助你。
当手机进入待机模式时,CPU 将停止工作,因此任何其他线程/应用程序/服务也将停止。
我使用 PowerManager 解决了这个问题,如下所示:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
wl.acquire();
..CPU will stay on during this section..
wl.release();
希望对您有所帮助!
关于android - 蓝牙服务器线程会待机吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5758606/