×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    183

    how to find the bluetooth devices

    i want to find the other bluetooth devices in my 6680, and i use the follow code, but i doesn't work, and once run it, i can exit the program as usually.


    Code:
    
    	public int findDevices() 
    	{
    		try
    		{
    			// cleans previous elements
    			btDevicesFound.removeAllElements();
    			// resets status variable
    			isBTSearchComplete = false;
    			LocalDevice local = LocalDevice.getLocalDevice();
    			DiscoveryAgent discoveryAgent = local.getDiscoveryAgent();
    			// start discovery of new devices 
    			discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this);
    			while ((!isBTSearchComplete)) 
    			{
    				//waits for a fixed time, to avoid long search
    				synchronized (this) 
    				{
    					this.wait(FindBt.BLUETOOTH_TIMEOUT);
    				}
    				// check if search is completed
    				if (!isBTSearchComplete) 
    				{ 
    					// search no yet completed so let's cancel it 
    					discoveryAgent.cancelInquiry(this);
    				}
    				
    			}
    			
    		}
    		catch (Exception e) 
    		{
    			e.printStackTrace();
    			setAlert("findDevices Exception" );
    		}
    		// returns the number of devices found 
    		return btDevicesFound.size();
    		
    	}


    i get this code from nokia wiki,
    could anyone tell me how to do this, thx a lot!

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    wenstory, are you looking for paired devices stored within your Nokia or are you looking for Bluetooth visible phone around of you? Instead of starting with wiki-code, I recommend a book because I do not like that thread/wait/synchronised stuff at all.

Similar Threads

  1. how to search for bluetooth devices
    By elaltaico in forum Mobile Java General
    Replies: 3
    Last Post: 2009-11-09, 05:57
  2. Bluesoleil Software
    By kencooper in forum Bluetooth Technology
    Replies: 9
    Last Post: 2008-08-29, 19:46
  3. problem in transfer data with Bluetooth in real devices
    By tortoisevn in forum Bluetooth Technology
    Replies: 1
    Last Post: 2006-11-07, 11:35
  4. unable to find bluetooth devices using j2me
    By vitalmd in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-02-16, 10:09
  5. How to find more bluetooth devices than one in discovery?
    By Mito1982 in forum Bluetooth Technology
    Replies: 1
    Last Post: 2004-03-25, 15:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×