Continuous Bluetooth Inquiry J2ME

5 pts.
Tags:
Bluetooth
J2ME
Mobile development
I'm trying to develop a midlet that will continuously inquiry for nearby devices. I want to test if it's possible to inquiry a device while he is inquiring too. I have done this continuous inquiry by doing an initial startInquiry and then calling the startInquiry again inside the inquiryCompleted event handler. After this i encountered two problems. The first was in the mobile emulator. The first inquiry doesn't give an error, but after that i get "BluetoothStateException: The previous device discovery is running". When i try this in the actual device (my personal cellphone) it doesn't throw an exception but it doesn't do anything else. It blocks on the startInquiry (the second one) and does nothing. The interface continues to work (since it blocked the thread of the event handler, i think). I've tried several solutions like calling cancelInquiry before the new startInquiry. I tried also (at least on the emulator) to put a delay before calling the next startInquiry. How do i do this?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Do you implement deviceDiscovered as a useful method, or just as a stub? I would think that once a device is discovered, this would be the time to make another call to startInquiry (after getting whatever info you want about the device, of course).

Also: startInquiry is supposed to be non-blocking. If it is blocking, there may be some other problem somewhere.

If you want to do more than one inquiry at the same time, I would think that you would need to do these on two separate threads of execution using a class that implements Runnable. Have you tried that? Also: what is the point of doing overlapping queries?

BTW, how long was your delay? I’d start with a one minute delay and then work down to the lowest possible number. I would think a delay of some length would have to be incorporated, otherwise you would drain the battery of a real device fairly quickly.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following