views:

41

answers:

0

I am trying to initiate a bluetooth device search in my java app. The agent.startInquiry seems to start but an exception is thrown from the catch block, and then I get an alert from deviceDiscovered() saying device discovered1. Is there is an exception, why is that deviceDiscovered is getting called? Can anyone please let me know if I am missing something? The code is here :

public void MyDeviceDiscovery()
 {
 try {
  local = LocalDevice.getLocalDevice();
 }catch(BluetoothStateException bse)
 {
  Dialog.alert("unknown exception");
 }
 agent = local.getDiscoveryAgent();

 devicesfound = new Vector();

 try {
  if(!agent.startInquiry(DiscoveryAgent.GIAC, this))
    {
   Dialog.alert("Start Enquiru error"); 
    }
 }
  catch(BluetoothStateException bse)
  {
   //Dialog.alert("unknown exception2"); 
   //Testing_Bluetooth_Class_Screen.testing.setText(bse.getMessage());
   //throw new Error(bse.getMessage());
   Dialog.inform("Exception startDeviceInquiry");
   Dialog.inform(bse.toString());
   System.exit(1);
  }
 }