tags:

views:

456

answers:

1

I am trying to get my Activity to enable Bluetooth with the Android 2.0.1 SDK, I am using some code straight from the documentation here: http://developer.android.com/guide/topics/wireless/bluetooth.html

Which is:

if (!mBluetoothAdapter.isEnabled()) {
    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}

I get an error at the REQUEST_ENABLE_BT part where Eclipse says it cannot be resolved. What am I doing wrong?

+2  A: 

The REQUEST_ENABLE_BT part is a request code that you should handle in your onActivityResult method. In that method you'll be notified whether or not enabling Bluetooth was successful.

In that code snippet they didn't show the definition of it, but it's just a constant integer so you can set it to any value you like.

See the documentation for startActivityForResult for more info about getting results back from activity launches.

Christopher