Hichem-elAbassi / j4me

Automatically exported from code.google.com/p/j4me
0 stars 0 forks source link

Getting a list of GPS devices sometimes fails. #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the GPS discovery in GPSDemoMidlet with a lot of bluetooth devices
around. Run on a Sony Ericsson w880i

What is the expected output? What do you see instead?

  Expected: A dialogue where a list of bluetooth devices are available for
selection.
  What I see instead: A dead program.

What version of the product are you using? On what operating system?

 1.0.2, on Sony Ericsson w880i

Please provide any additional information below.

  The problem can be fixed by patching BluetoothDeviceDiscovery.java in
this way:

Index:
C:/w/j4m/j4me/J4ME/src/org/j4me/bluetoothgps/BluetoothDeviceDiscovery.java
===================================================================

---
C:/w/j4m/j4me/J4ME/src/org/j4me/bluetoothgps/BluetoothDeviceDiscovery.java
(revision 68)
+++
C:/w/j4m/j4me/J4ME/src/org/j4me/bluetoothgps/BluetoothDeviceDiscovery.java
(working copy)
@@ -139,9 +139,18 @@
        {
            RemoteDevice device = (RemoteDevice)devices.nextElement();

-           String name = device.getFriendlyName( false );
-           String address = device.getBluetoothAddress();
+           String name = null;
+           String address;

+           address = device.getBluetoothAddress();
+           
+           try {
+               name = device.getFriendlyName( false );
+           } catch (IOException e){
+               Log.debug("Got an IOException when getting friendlyName for device " +
address);
+           }
+           
+           
            if ( name == null )
            {
                name = address;

Original issue reported on code.google.com by la3...@gmail.com on 15 May 2008 at 2:01

GoogleCodeExporter commented 9 years ago
Fixed.  Awesome catch.  Thanks for the code.

Original comment by deanbro...@gmail.com on 15 May 2008 at 4:57