我需要实现一个后台服务,通过 BLE 扫描设备并在发现时与我的 BLE 设备连接。所以我的问题是我应该使用哪些服务?
- Intent 服务
- 作业调度器
最佳答案
我建议使用服务
(IntentService
也可以达到目的)。 Android documentation巧妙地捕捉所涉及的主要步骤。示例代码使用 service
来演示 API 用法:-
public class BluetoothLeService extends Service {
private final static String TAG = BluetoothLeService.class.getSimpleName();
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
.........
.........
.........
关于java - BLE 连接的后台服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44853312/