mkaouer / j4me

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

GSP thing - JSR179LocationProvider nullpointer #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
J4ME Version 1.0.2
JSR179LocationProvider.java

around row 165:
javax.microedition.location.Location location =
javax.microedition.location.LocationProvider.getLastKnownLocation();

this may return "null" as Location object (Symbian OS 9.3 at least)

i suggest changing the function to something like this so that the user can
check to null (which is done in the example anyway):

protected Location getLastKnownLocationToProvider ()
{
    javax.microedition.location.Location location =
javax.microedition.location.LocationProvider.getLastKnownLocation();
    if (location != null && location.isValid()){
        org.j4me.bluetoothgps.Location j4me = convertLocation( location );
        return j4me;
    }
    return null;
}

I found this bug by playing around with bluetooth example on my N95 (which
supports bluetooth api and jsr179 api)

cheers
michael

Original issue reported on code.google.com by michael....@gmail.com on 4 May 2008 at 11:14

GoogleCodeExporter commented 9 years ago
I agree with you that an invalid location is more consistent with the rest of 
the API
then returning null is.  However, the JSR-179 specification says, "null is 
returned
if the implementation doesn't have any previous location information."  In this 
case
we want to stick with the spec.

Thanks for the heads up though.  I had to go back and check it myself :)

Original comment by deanbro...@gmail.com on 5 May 2008 at 4:36