如何通过蓝牙从芯片传输数据?
我正在尝试开发一个 Android 应用程序,它将使用蓝牙功能将数据从芯片传输到 Android 手机。我根本没有更改开发人员网站上教程中的代码。
我收到以下错误:
_context cannot be resolved as a variable
这是我的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocalBluetoothDevice localBT = LocalBluetoothDevice.initLocalDevice(_context);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
I am trying to develop an android application that will use Bluetooth capabilities to transfer data from a chip to an Android phone. I have not changed the code from the tutorial on the developer's website at all.
I am getting the following error:
_context cannot be resolved as a variable
Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocalBluetoothDevice localBT = LocalBluetoothDevice.initLocalDevice(_context);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
或
Use
or