mrossen Active Member Licensed User Longtime User May 10, 2012 #1 Hi, I trying to detect if the user enable/disable bluetooth I use the BluetoothAdmin object, but it seems that I not understand it right? Code: Copy Dim BluetoothAdmin1 As BluetoothAdmin Sub BluetoothAdmin1_StateChanged (NewState As Int, OldState As Int) Log(NewState) Log(OldState) End Sub Mogens
Hi, I trying to detect if the user enable/disable bluetooth I use the BluetoothAdmin object, but it seems that I not understand it right? Code: Copy Dim BluetoothAdmin1 As BluetoothAdmin Sub BluetoothAdmin1_StateChanged (NewState As Int, OldState As Int) Log(NewState) Log(OldState) End Sub Mogens
Erel B4X founder Staff member Licensed User Longtime User May 11, 2012 #2 The values should match one of the constant values listed here: Basic4android - Serial You can also see this example: Android Bluetooth / BluetoothAdmin Tutorial Upvote 0
The values should match one of the constant values listed here: Basic4android - Serial You can also see this example: Android Bluetooth / BluetoothAdmin Tutorial
mrossen Active Member Licensed User Longtime User May 12, 2012 #3 Hi, I have read the doc. It says : StateChanged event is raised whenever the adapter state changes. The new state and the previous state are passed. The values correspond to the STATE_xxxx constants. As I understand that, is when the Bluetooth adapter changes its state the _StateChanged sub it fired? This can I not get to work!! I have the StateChanged sub in a service running in the background, and would like to see when the bluetooth adapter is turned on/off. Mogens Upvote 0
Hi, I have read the doc. It says : StateChanged event is raised whenever the adapter state changes. The new state and the previous state are passed. The values correspond to the STATE_xxxx constants. As I understand that, is when the Bluetooth adapter changes its state the _StateChanged sub it fired? This can I not get to work!! I have the StateChanged sub in a service running in the background, and would like to see when the bluetooth adapter is turned on/off. Mogens
Erel B4X founder Staff member Licensed User Longtime User May 12, 2012 #4 Did you initialize BluetoothAdmin? Upvote 0
mrossen Active Member Licensed User Longtime User May 13, 2012 #5 Yes, with: Code: Copy BluetoothService.BluetoothAdmin1.Initialize("BluetoothAdmin1") Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 13, 2012 #6 You should initialize the object from the service (usually by calling StartService and then initialize the service in Service_Create). Otherwise the event will try to fire in the activity context. Upvote 0
You should initialize the object from the service (usually by calling StartService and then initialize the service in Service_Create). Otherwise the event will try to fire in the activity context.
mrossen Active Member Licensed User Longtime User May 13, 2012 #7 Thanks Erel, Now it is working perfect Mogens Upvote 0