How to move Bluetooth activity into a Service
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The application gives the users 2 connection options, USB and Bluetooth. USB works fine. I have obtained sample codes for Bluetooth connection, however they are designed to work as activity. I tried to do it in a Service but failed. BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); startService(new Intent(this, MyService.class)); <service android:enabled="true" android:name=".MyService" /> enter code here I need to establish Bluetooth communication with a device that is already paired and its MAC address is known. So