JSR - 179 LocationAPI Not Working On 5800ExpressMusic
Hello,
This is quite a funny situation I am finding myself in. A few days back, I wrote a simple, Midlet which captures the Lat/Lng value, and stores it in a file. I was using an E72 at that point of time. Now, when I try running the same code on a 5800, I don't get the desired output.
1. I have not made any significant changes to the code since then,
2. I don't have access to an E72 at this point of time, so I can't retest it on the same device,
3. I have checked the specs for 5800, and it supports JSR-179, and has a GPS chip in it as well.
Can anyone please help me out a little, with this?
Code Snippet :
[CODE]// GPS location related
public static int GPS_horizontalAccuracy = 100;
public static int GPS_locationFixTimeout = 60;
// set the criteria and get the location provider
Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(test.GPS_horizontalAccuracy);
try {
// marker
form.append("\n Entered Try-Catch Block...");
LocationProvider locationProvider = LocationProvider.getInstance(criteria);
// marker
form.append("\n Got Instance...");
Location location = locationProvider.getLocation(test.GPS_locationFixTimeout);
// marker
form.append("\n Got Locational Fix...");
Coordinates coordinates = location.getQualifiedCoordinates();
// marker
form.append("\n Got Coordinates...");
location_str = "(" + coordinates.getLatitude() + ", " + coordinates.getLongitude() + ")";
// marker
form.append("\n Done!");
} catch (LocationException e) {
form.append("LocationException in getLocation");
form.append(e.getMessage());
} catch (InterruptedException e) {
form.append("InterruptedException in getLocation");
form.append(e.getMessage());
} catch (IOException e) {
form.append("IOException in getLocation");
form.append(e.getMessage());
}[/CODE]
Expected Output :
Entered Try-Catch Block...
Got Instance...
Locational Fix...
Got Coordinates...
Done!
Actual Output :
Entered Try-Catch Block...
Got Instance...
LocationException in getLocation
Location request timed out
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
It looks that your 5800Xm is not able to get the GPS lock and hence it gives time out.
Try OVI-maps on this device or google maps or device inbuilt location app and once you get the GPS lock in that app, try your app at the same moment, it will start working.
Check settings, A-GPS and all other ways to get GPS lat/long should be selected in settings.
thanks,
Ekta
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
I checked all the settings. They are proper. I also tested on a host of other devices as well. Its STILL not working. Can anyone please suggest anything here? I am thinking, its some configuration error. There can't be much wrong with this code. Its only a bunch of API calls. Any pointers will be helpful...
-Rohitesh.
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
I'd try different Criteria's... For example on some devices setting a Power Criteria will simply stop the provider providing any Locations...
Also have you specifically tried what ektasrv has asked ? As in have you tried the standard Nokia Maps app on the device ? Does that one actually receive GPS positions ?
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
Rohitesh,
Its important that you first check if the GPS chip on the device is working or not, so try OVI maps and let us know the results? are getting a GPS fix.
thanks,
Ekta
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
@ektasrv @Tiger79
There's a small problem. I don't have access to a phone that has a GPS chip, till Monday! :( So, gotta wait for another day or two, for that. I will update here, as soon as I can get my hands on one.
Cheers,
Rohitesh.
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
One more thing - you should check - your code contains line --> public static int GPS_locationFixTimeout = 60;
60 => 60 seconds.... and it has been seen that using the device in open Air, the first GPS fix may take a time around 10 to 15 mins even so increase it and try.
Or even better try out with -1, the default timeout.
You will notice, if you get a GPS fix on OVI map once and then if you switch to your app... you will get the fix very fast.
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
Sorry,
I thought you were developing specifically on a 5800XM, which does have a GPS chip :P
Anyways first check if the GPS is working at all, even though the chances are pretty small it might be that the GPS receiver is simply broken...
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
@ektasrv @Tiger79
I tried the following, and still no positive results :
1. First accessed Nokia Ovi Maps. Got a location fix on the map that it displayed. Exited. Then ran my app. It still couldn't get a locational fix, and gave a time out.
2. Also increased the timeout limit to 120 (2mins), but it still didn't work.
I am really at my wits' end. This is a simple Hello World program that I am running here. How can this fail???
-Rohitesh
P.S.
* Device I am using : 5800ExpressMusic
* GPS Settings :
Positioning Methods : Assisted GPS (selected), Integrated GPS (selected), Bluetooth GPS (selected), Network based (selected)
* I am running these tests outdoors, with a clear line of sight with the sky
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
As Ekta suggested, try to increase the time-out to 10 to 15 mins and see if your application is able to get the fix. Even 2 min's can be very less to get a GPS Fix.
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
[QUOTE=rohiteshd;745012]@ektasrv @Tiger79
I tried the following, and still no positive results :
1. First accessed Nokia Ovi Maps. Got a location fix on the map that it displayed. Exited. Then ran my app. It still couldn't get a locational fix, and gave a time out.
2. Also increased the timeout limit to 120 (2mins), but it still didn't work.
I am really at my wits' end. This is a simple Hello World program that I am running here. How can this fail???
-Rohitesh
P.S.
* Device I am using : 5800ExpressMusic
* GPS Settings :
Positioning Methods : Assisted GPS (selected), Integrated GPS (selected), Bluetooth GPS (selected), Network based (selected)
* I am running these tests outdoors, with a clear line of sight with the sky[/QUOTE]
Hi Rohit,
Try to test your application while Ovi Maps is runing in the background after Ovi map gets the Fix without exiting it and try time-out vaule of -1 or 30x60 = 30 mins - hope you will get the fix in your app.
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
Actually instead than assuming you already have a Location like in your code I would implement the LocationListener interface...
And simply get a Location when it's available, have a look at this wiki article :
[url]http://wiki.forum.nokia.com/index.php/Help_obtaining_GPS_fix[/url]
Re: JSR - 179 LocationAPI Not Working On 5800ExpressMusic
Try increasing the HorizontalAccuracy to 5000 and check.
And yes, just like Tiger I would also recommand using LocationListener mechanism as people have faced lot of problems realted to time-out while using location polling methods to get the location from location provider.
Fro API doc you can see:
[B]setLocationListener[/B]
public abstract void setLocationListener(LocationListener listener,
int interval,
int timeout,
int maxAge)
Adds a LocationListener for updates at the defined interval. The listener will be called with updated location at the defined interval. The listener also gets updates when the availablilty state of the LocationProvider changes.
Passing in -1 as the interval selects the default interval which is dependent on the used location method. Passing in 0 as the interval registers the listener to only receive provider status updates and not location updates at all.
Only one listener can be registered with each LocationProvider instance. Setting the listener replaces any possibly previously set listener. Setting the listener to null cancels the registration of any previously set listener.
The implementation shall initiate obtaining the first location result immediately when the listener is registered and provide the location to the listener as soon as it is available. Subsequent location updates will happen at the defined interval after the first one. If the specified update interval is smaller than the time it takes to obtain the first result, the listener shall receive location updates with invalid Locations at the defined interval until the first location result is available.
The timeout parameter determines a timeout that is used if it's not possible to obtain a new location result when the update is scheduled to be provided. This timeout value indicates how many seconds the update is allowed to be provided late compared to the defined interval. If it's not possible to get a new location result (interval + timeout) seconds after the previous update, the update will be made and an invalid Location instance is returned. This is also done if the reason for the inability to obtain a new location result is due to the provider being temporarily unavailable or out of service.
For example, if the interval is 60 seconds and the timeout is 10 seconds, the update must be delivered at most 70 seconds after the previous update and if no new location result is available by that time the update will be made with an invalid Location instance.
The maxAge parameter defines how old the location result is allowed to be provided when the update is made. This allows the implementation to reuse location results if it has a recent location result when the update is due to be delivered. This parameter can only be used to indicate a larger value than the normal time of obtaining a location result by a location method. The normal time of obtaining the location result means the time it takes normally to obtain the result when a request is made. If the application specifies a time value that is less than what can be realized with the used location method, the implementation shall provide as recent location results as are possible with the used location method. For example, if the interval is 60 seconds, the maxAge is 20 seconds and normal time to obtain the result is 10 seconds, the implementation would normally start obtaining the result 50 seconds after the previous update. If there is a location result otherwise available that is more recent than 40 seconds after the previous update, then the maxAge setting to 20 seconds allows to return this result and not start obtaining a new one.
Parameters:
[B]listener [/B]- the listener to be registered. If set to null the registration of any previously set listener is cancelled.
[B]interval [/B]- the interval in seconds. -1 is used for the default interval of this provider. 0 is used to indicate that the application wants to receive only provider status updates and not location updates at all.
[B]timeout [/B]- timeout value in seconds, must be greater than 0. if the value is -1, the default timeout for this provider is used. Also, if the interval is -1 to indicate the default, the value of this parameter has no effect and the default timeout for this provider is used. If the interval is 0, this parameter has no effect.
[B]maxAge [/B]- maximum age of the returned location in seconds, must be greater than 0 or equal to -1 to indicate that the default maximum age for this provider is used. Also, if the interval is -1 to indicate the default, the value of this parameter has no effect and the default maximum age for this provider is used. If the interval is 0, this parameter has no effect.
[B]Throws[/B]:
java.lang.IllegalArgumentException - if interval < -1, or if (interval != -1) and (timeout > interval or maxAge > interval or (timeout < 1 and timeout != -1) or (maxAge < 1 and maxAge != -1))
java.lang.SecurityException - if the calling application does not have a permission to query the location information