我正在尝试开发一个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);
}
}发布于 2011-07-27 02:06:52
使用
LocalBluetoothDevice localBT = LocalBluetoothDevice.initLocalDevice(this);或
Context context = this;
LocalBluetoothDevice localBT = LocalBluetoothDevice.initLocalDevice(context);https://stackoverflow.com/questions/6834431
复制相似问题