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

Native Development

Reply
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010
My Device: Not Specified
Accepted Solution

Is Geolocation available for BB10?

Hello,

 

I'm an experienced BB developer that is now switching to BB10. I attended a BBJam event last month, and I was lucky enough to win a BB Dev Alpha device. I'm working on a Native C++ Cascades application that reads GPS information. I used the following code to get the geolocation data, however I never receive any event. The code stays on bps_get_event (this code is blocking, so as long as it doesn't receive events it stays there). Note that I tested my app on the real device (Dev Alpha):

 

void GpsApp::listenForGpsEvents() {
	int rc = BPS_FAILURE;
	
	// Initialize access to the BPS system
	rc = bps_initialize();
	if (rc)
		return;
	
	// Register to receive GPS Events - if we can't then we can't proceed any further
	rc = geolocation_request_events(0);
	if (rc)
		bps_shutdown();
	
	// Get geolocation events once a second, which is the most often that they
	geolocation_set_period(1);
	
	// Pointer to the event that will be dequeued
	bps_event_t *event = NULL;
	
	// Infinite loop for the moment
	while(1) {
		// Blocking wait ( -1 ) for BPS events (including geolocation events)
		rc = bps_get_event(&event, -1);
		
		if (!rc) {
			if (bps_event_get_domain(event) == geolocation_get_domain()) {
				// Handle GPS event
				handleGpsEvent(event);
			}
		}
	}
	
	// Stop geolocation events
	geolocation_stop_events(0);
	
	// Close access to the BPS system
	bps_shutdown();
}

 

Also note that I added some code to listen for accelerometer events as well and it works fine. Do you know if geolocation is available on the current version of the NDK or should we wait for the next NDK release?

 

Thanks,

Please use plain text.
BlackBerry Development Advisor
anhu
Posts: 54
Registered: ‎10-26-2011
My Device: Playbook
My Carrier: Rogers

Re: Is Geolocation available for BB10?

So, I'd like to make 2 suggestions: 

 

1.  Put your playbook near a window.  (so it can get geolocation information.)

2.  Make sure WiFi is on and connected to a router. (it can get geolocation info from the network)

 

If it still doesn't work, please let us know. 

 

Anthony

Please use plain text.
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010
My Device: Not Specified

Re: Is Geolocation available for BB10?

Thanks for your response!

Yes, I tried both suggestions with no luck. I don't get any single geolocation event. I guess I'll have to wait until next NDK release...
Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Is Geolocation available for BB10?

It is available.  A sample was tested on one device.

I expect it is just taking a long time to lock to satelites in your case.

 

Stuart

Please use plain text.
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010
My Device: Not Specified

Re: Is Geolocation available for BB10?

Thanks. Maybe my hardware is defective because I left the device on open air for about 1h and I didn't receive a single geolocation event. The native geolocation sample didn't work neither.
Please use plain text.
BlackBerry Development Advisor (Retired)
selom
Posts: 60
Registered: ‎05-10-2012
My Device: Blackberry 10 Alpha
My Carrier: none

Re: Is Geolocation available for BB10?

Hello, I wanted to make you aware that there is an issue logged in the Jira system about the Geolocation problem you are experiencing.

 

Compared to the Playbook, the BB10 alpha device is much slower and less responsive to reading geolocation events. You can comment or vote on the issue at

 

https://www.blackberry.com/jira/browse/BBTEN-8

 

Cheers

Selom

Please use plain text.
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010
My Device: Not Specified

Re: Is Geolocation available for BB10?

Thanks selom,

 

I'm happy to read this. Then I'm sure it will be fixed in future firwmare upgrades of the Dev Alpha. I guess I'll have to remove the Cascades part from my code and test it on the Playbook.

 

Cheers,

Please use plain text.