diff --git a/app/src/main/kotlin/io/treehouses/remote/bases/FragmentViewModel.kt b/app/src/main/kotlin/io/treehouses/remote/bases/FragmentViewModel.kt index 62fda3ece..206d3e11e 100644 --- a/app/src/main/kotlin/io/treehouses/remote/bases/FragmentViewModel.kt +++ b/app/src/main/kotlin/io/treehouses/remote/bases/FragmentViewModel.kt @@ -110,9 +110,14 @@ open class FragmentViewModel(application: Application) : AndroidViewModel(applic * Load the bluetooth service and update the handler and connection status */ fun loadBT() { - mChatService = getApplication().getCurrentBluetoothService()!! - mChatService.updateHandler(mHandler) - _connectionStatus.value = mChatService.state + val bluetoothService = getApplication().getCurrentBluetoothService() + if (bluetoothService != null) { + mChatService = bluetoothService + mChatService.updateHandler(mHandler) + _connectionStatus.value = mChatService.state + } else { + _connectionStatus.value = Constants.STATE_NONE + } } /**