Skip to content Skip to sidebar Skip to footer

Android: Monitoring Bluetooth Discovery - What Does This Compile Error Mean?

I'm learning Bluetooth programming on Android using the Wrox Professional Android 2 Application Development book. The discovery monitor example (pg 432) has this code snippet:

Solution 1:

Your problem is that you defined variables dStarted and dFinished as locals for discoveryMonitor BroadcastReceiver, That way, you can't use them in registerReceiver(...)

You have to define them as global, or use

registerReceiver(discoveryMonitor, new 
                 IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED));

instead.

Post a Comment for "Android: Monitoring Bluetooth Discovery - What Does This Compile Error Mean?"