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

Android™ Runtime Development

Reply
Developer
rakesh86shankar
Posts: 987
Registered: ‎05-22-2009
My Device: Not Specified

How to get GPS Location

Hi,

 

I am trying the find the GPS location.I am getting lat and long as full,

 

Basically i have qns regarding GPS

 

1)First of all Is there any option to Check GPS is enablered or not,If so where can i find them?

 

2)While installing the application ,it does not ask permissions regarding GPS location

 

I tried added something like 

 

<rimermissions> <rimermit>read_geolocation</rimermit> </rimermissions>

 

But there was not much of change with this code.

 

 

Did anyone tried using GPS.

 

Thanks

Rakesh

 

Please use plain text.
Regular Contributor
Fraggle222
Posts: 84
Registered: ‎01-31-2013
My Device: Simulator !!!
My Carrier: 8608800458

Re: How to get GPS Location

Are you developing this as an Android app for BB10? If so just use the standard Android techniques and permissions. I am using GPS and so far so good (at least on simulator).

You can use LocationManager.isProviderEnabled() method to see if it is enabled.

In Manifest You need: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Then get a LocationManager instance and call lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0F, this);
Please use plain text.
Developer
rakesh86shankar
Posts: 987
Registered: ‎05-22-2009
My Device: Not Specified

Re: How to get GPS Location

Thanks for the info,I will check it.To retreive lat and long ,Whether stand alone GPS will fetch the location or do i require SIM to get the location?

Please use plain text.
Regular Contributor
Fraggle222
Posts: 84
Registered: ‎01-31-2013
My Device: Simulator !!!
My Carrier: 8608800458

Re: How to get GPS Location

You don't need cell service for GPS an Android devices. On Blackberry, I would assume the same. It's a different technology, but you never know what the carrier or manufacturer will build into their system. Verizon used to disable the GPS chip on my old blackberry unless you paid them extra. But generally speaking they are completely independent of each other.
Please use plain text.
Developer
neilhogg69
Posts: 34
Registered: ‎05-11-2012
My Device: Bold 9900
My Carrier: Vodacom

Re: How to get GPS Location

We use the requestLocationUpdates method but every time we get null lats and longs for both GPS and NETWORK providers. The isProviderEnabled returns true for both providers.
Please use plain text.
Regular Contributor
Fraggle222
Posts: 84
Registered: ‎01-31-2013
My Device: Simulator !!!
My Carrier: 8608800458

Re: How to get GPS Location

Simulator or device? If simulator you'll need the Simulator control application to set a location.
Please use plain text.
Contributor
abenoit
Posts: 16
Registered: ‎01-16-2013
My Device: BB10 Dev Alpha
My Carrier: Free

Re: How to get GPS Location

I have the same problem (on an actual Z10 device with a SIM card) :

 

TelephonyManager.getCellLocation() returns null

LocationManager.getLastKnownLocation(provider) returns null for all avaiable providers

Any listner I register with LocationManager.requestLocationUpdates) is never called

 

Any idea ?

 

Any input from someone from Blackberry or is it useless to hope for a geolocation feature on Android apps ported on Blackberry 10 ?

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: How to get GPS Location

Is Location Services enabled in the OS Settings?

Please use plain text.
Regular Contributor
Fraggle222
Posts: 84
Registered: ‎01-31-2013
My Device: Simulator !!!
My Carrier: 8608800458

Re: How to get GPS Location

Note that on the Z10 device, I have discovered that if the Screen is Off (via power button click or timeout) then the Activity will not receive location updates (I've opened a separate thread on this issue).

 

If the screen is on and Activity has registered for Location updates then it definitely will get them. 

 

To register for location updates:

 

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0F, this);

       

This works fine on actual Z10 device (and simulator), except as noted above if power button is clicked or screen times out.

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: How to get GPS Location

Do you hold a wake lock when attempting to get updates when the screen is off?

Please use plain text.