Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in retrieving latitude and longitude of the device

Either with the device or with the permissions or with the carrier. 

 

But in my experience. most OS 6.0 WiFi enabled devices, running just WiFi (no Sim) can still get the location from the WiFi network.  Of course that assumes someone has mapped your WiFi network, which it appears they have for most WiFi networks in the UK.  Other places perhaps not.

 

Another thing to try is Blackberry Maps and ask it to map your current location.  That assumes of course you are in a country which is mapped.  But it will have a good go at finding your location.

 

In later OS's if you go into Location Settings, it will display the device's location. There is usually a menu option to refresh that location.  Give that a try to see if that helps. 

Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in retrieving latitude and longitude of the device

I was just about to write about the Location Settings.

Last time i got the latitude and longitude on my device is Feb 2013.

And when i refresh it, after 2-3 minutes i got a message of updation failure.

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in retrieving latitude and longitude of the device

Take it outside and try again.

 

What sort of device is it?

Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in retrieving latitude and longitude of the device

Its Blackberry 9790 smartphone (3G,Wi-Fi)

7.1 bundle 1647.

 

I have tried the code on Blackberry 9300 smartphone  OS 6.0 even then i am not getting the latitude and longitude.

But if i refresh the location on device settings i am getting the location but it wil take time 3-4 minutes mininum.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in retrieving latitude and longitude of the device

3-4 minutes is normal for a GPS fix.  Both phones have a GPS chip so both should get a location. 

Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in retrieving latitude and longitude of the device

I have used the Diagnostic extended sample but i am not getting the location through any mode.

Then wahts the problem now?

Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in retrieving latitude and longitude of the device

Hi

I have used the SimpleLocation API Demo sample.

In that i have used geolocation mode and i am getting the location.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in retrieving latitude and longitude of the device

Geolocation id cell site - you should have that optin on the Disgnostic facility and if it works for Simple, then it should work there also.  But anyway, you have a location. 

Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in retrieving latitude and longitude of the device

Hey

I am using this code to get the location.

if(RadioInfo.getState()==RadioInfo.STATE_ON && isSimAvailable())
                   {    
                       enableGPS();
                       try
                       {
                           BlackBerryCriteria myCriteria = new BlackBerryCriteria();
                           myCriteria.setHorizontalAccuracy(30000);
                           myCriteria.setVerticalAccuracy(30000);
                           myCriteria.setCostAllowed(true);
                           myCriteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);
                           myCriteria.setMode(GPSInfo.GPS_MODE_CELLSITE);
                             
                           BlackBerryLocationProvider myProvider;
                           myProvider  = (BlackBerryLocationProvider) LocationProvider.getInstance(myCriteria);
                            
                           BlackBerryLocation myLocation;
                           myLocation = (BlackBerryLocation) myProvider.getLocation(3000);
                           latitude = String.valueOf(myLocation.getQualifiedCoordinates().getLatitude())';
                           logitude = String.valueOf(myLocation.getQualifiedCoordinates().getLongitude());    
                        
                           
                           latitudeLabel = new LabelField("Latitude : "+latitude);
                           longitudeLabel = new LabelField("Longitude : "+logitude);
                           add(latitudeLabel);
                           add(longitudeLabel);
                          
                      
                       }
                       catch (Exception e)
                       {
                           e.toString();
                       }
                   }

 

 

In my console i am getting this.

 

Acquired valid locationlat,longt.

But why its not displaying to the label field??

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in retrieving latitude and longitude of the device

You are running blocking code on the Event Thread:

 

myLocation = (BlackBerryLocation) myProvider.getLocation(3000);

This tells the location provider it can wait 3 seconds to get a location.  So you are potentially blocking for 3 seconds. 

 

I guess this might block as well:

enableGPS();

 

Please don't do this. 

 

This has been mentioned to you on numerous other Threads, with links to the relevant articles.  So I'm not going to repeat this information. 

 

It may be causing your problem, it may not, I don't know and we can't tell from this code. 

 

Regarding your question, why don't you debug your code?  You could step through it and see which parts are executed and which are not.  Alternatively, you could add some logging code in there to help this.  You tell us the last statement it has actually executed and then we might be able to help.  But I think if you find that you will also find your problem, which seems like a good thing to do anyway.