Here we will discuss about a sample program to search for Bluetooth enabled devices around your mobile phone. J2ME community has defined a standard for Bluetooth communication in JSR 82, which describes the standard APIs used to communicate with Bluetooth enabled devices. The JSR 82 contains the following packages to exchange data between two devices.
- javax.bluetooth – Core Bluetooth API
- javax.obex -- APIs for Object Exchange (OBEX) protocol
Most of the below code is self explanatory. The actual scanning is started when the discoveryAgent.startInquery() method is called. So, Whenever a new device is found then deviceDiscovered() method will be invoked and once the discovery process is complete then inquiryCompleted() method is called.