public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BluetoothManager btManager = new BluetoothManager(this);
setContentView(R.layout.main);
if (!btManager.isEnabled()) {
btManager.requestBluetoothEnable();
discoveryStarted = false;
} else {
if (btManager.isDeviceSetNullOrEmpty()) {
btManager.startDiscovery();
discoveryStarted = true;
}
}
}
@Override
public void onResume(){
super.onResume();
if( btManager.isEnabled() && discoveryStarted == false ){
即使我初始化了我的 btManager 类(几个蓝牙类的包装器),我也在这里得到一个 NullPointer 异常。