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

Adobe AIR Development

Reply
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Simulate GPS and Accelerometer?

John, I don't see how network providers would be involved with GPS.  GPS receivers operate on signals received directly from the satellites, and don't require any interaction with other terrestrial systems. 

 

I have an HTC Dream, for example, that has no Rogers SIM card in it and it works rather nicely as a geocaching tool (with map regions preloaded over wifi before I leave the house).

 

(Also, since the PlayBook has no cellular radio of its own, again a network provider wouldn't necessarily be in the picture.  Lots of people will buy this thing even if they don't own a BB phone.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Simulate GPS and Accelerometer?

In some cell phone, there are hooks that can be enabled or disabled for network providers depending on their needs.  The same BB phone for one provider can deactivate feature X while it is enabled for another provider.  I spent a many an hour argueing with Verizon in why they would disable GPS for 3rd party applications but it worked fine for their own navigator application.  Their reason was typically that they are safegaurding the phone and customer against unapproved applications.  However, those same application would be allowed on another BB phone, just typically not the current models.  Basically, it is a way for network providers to force consumers to only access certain content via their own 'for sale" products or services.

 

The PB will most likely be sold mostly by network providers.  If a large network provider asked BB to add firmware hooks on various features, BB will of course do that if it means increase sales.

 

I dislike this policy and a lot of retail stores are not aware of this practice until a customer tries to install an application that has been declared "unsafe" on certain devices.

 

Let's just hope the PB will remain "open" in this area.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Simulate GPS and Accelerometer?

I guess answering my own question again: this post at the CrackBerry.com site reports on the #MeetThePlayBook event in Toronto two days ago, and says that again RIM people have clearly stated that there is a GPS module on-board.  I guess I'll accept it as conclusive.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: Simulate GPS and Accelerometer?

i'm happy there will be GPS on the device.  it opens up a huge area for applications.  for years you could buy a dashboard GPS unit for your car that do not require any wireless plan.


PlayBook Applications:
Drop Swatch
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Simulate GPS and Accelerometer?

@Darkin: imagine hooking up this bad boy onto your dashboard/windsheild Smiley Very Happy

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Simulate GPS and Accelerometer?

Here is the simulator for GPS features.  Works pretty well to get around the fact that the simulator does not simulate GPS and I dont have a PB (yet).  This simulator is around Charlottesville, VA.

 

package gps
{
	import flash.events.Event;
	import flash.events.GeolocationEvent;
	import flash.events.TimerEvent;
	import flash.sensors.Geolocation;
	import flash.utils.Timer;

public class GpsPositionDriver
{
  private var timer        : Timer = new Timer( 2000 );
  private var gps_service  : Geolocation = null;
  private var last_step    : int = 0;
  private var data         : Array = new Array();
  private var start_time   : Number = 0;

//////////////////////////////////////////////////////////////////
public function GpsPositionDriver( sensor : Geolocation )
{
	this.gps_service = sensor;
	this.timer.addEventListener( TimerEvent.TIMER, Ping );
			
	var now : Date = new Date();
	this.start_time = now.getTime();
			
	// data
	this.data.push( { altitude : 600, heading : 45, hacc : 100, vacc : 100, latitude : 38.020654096686464, longitude : -78.53692074499511, speed : 10 } );
	this.data.push( { altitude : 601, heading : 46, hacc : 100, vacc : 100, latitude : 38.02160072090434, longitude : -78.53949566564941, speed : 12 } );
	this.data.push( { altitude : 601, heading : 270, hacc : 100, vacc : 100, latitude : 38.022090932211185, longitude : -78.54177017889404, speed : 13 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02234448849692, longitude : -78.54357262335205, speed : 15 } );
		
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02242900706387, longitude : -78.5454179831543, speed : 2 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.022344488497076, longitude : -78.54835768423462, speed : 3 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02227687357351, longitude : -78.55168362341308, speed : 5 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02210783599131, longitude : -78.55638285360718, speed : 1.5 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02187118272113, longitude : -78.56230517111206, speed : 1 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02166833645269, longitude : -78.56691857061767, speed : 5.5 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02166833645269, longitude : -78.57022305212402, speed : 5 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.022006413255085, longitude : -78.57387085638427, speed : 5 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02283469482895, longitude : -78.57738991461181, speed : 2.5 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.02454193955506, longitude : -78.58196039877319, speed : 17 } );
	this.data.push( { altitude : 601, heading : 275, hacc : 100, vacc : 100, latitude : 38.0275675527831, longitude : -78.58826895437622, speed : 8 } );
	this.data.push( { altitude : 601, heading : 290, hacc : 100, vacc : 100, latitude : 38.029832455209, longitude : -78.59288235388183, speed : 7 } );
	this.data.push( { altitude : 601, heading : 300, hacc : 100, vacc : 100, latitude : 38.0320803861371, longitude : -78.59751721105957, speed : 10 } );
	this.data.push( { altitude : 601, heading : 25, hacc : 100, vacc : 100, latitude : 38.033009961471976, longitude : -78.59901924810791, speed : 12 } );
	this.data.push( { altitude : 601, heading : 30, hacc : 100, vacc : 100, latitude : 38.034598662916025, longitude : -78.6012508460083, speed : 11 } );

			
}
		
/////////////////////////////////////////////////////////////
public function Start() : void
{
	this.timer.start();
}

/////////////////////////////////////////////////////////////
public function Stop() : void
{
	this.timer.stop();
}

/////////////////////////////////////////////////////////////////
private function Ping( event : Event ) : void
{
	var now : Date = new Date();
			
	var evt : GeolocationEvent = new GeolocationEvent( GeolocationEvent.UPDATE );
	evt.altitude           = this.data[this.last_step].altitude;
	evt.heading            = this.data[this.last_step].heading;
	evt.latitude           = this.data[this.last_step].latitude;
	evt.longitude          = this.data[this.last_step].longitude;
	evt.horizontalAccuracy = this.data[this.last_step].hacc;
	evt.verticalAccuracy   = this.data[this.last_step].vacc;
	evt.speed              = this.data[this.last_step].speed;
	evt.timestamp = now.getTime() - this.start_time; // ms from runtime initialized

	this.gps_service.dispatchEvent( evt );
			
	this.last_step++;
	if( this.last_step == this.data.length )this.last_step = 0; // reset
			
    }
  }
}

 

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Simulate GPS and Accelerometer?

hey john,

 

thats good work! *bookmarks* ill have to try this out Smiley Happy

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 323
Registered: ‎05-07-2009
My Device: BlackBerry Z10, PlayBook, 9900
My Carrier: Telus

Re: Simulate GPS and Accelerometer?

Hi John,

 

Your code looks like it will work great as a substitute while awaiting GPS functionality.

 

I tried adding it to my application but (I feel silly about this) I have no idea what I need to pass into it to instanciate it?

 

var foo:GpsPositionDriver = GpsPositionDriver(whatGoesHere);

 

If you could provide a quick "Hello World" of how to use it I would greatly apreciate it.

 

Cheers,

Steve


PlayBook Apps: DataMine, Dots + Boxes, 5 Marbles
BlackBerry SmartPhone Apps: 5 Marbles Soon: **** (D.Z.A), ****Quest, **** Challenge, VaultCracker, DevBrowser, Radial****
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Simulate GPS and Accelerometer?

[ Edited ]

In the view that you normally listen for GPS events, add GpsPositionDriver as an attribute 

 

 

// attributes:

public var gps_service : Geolocation = new Geolocation();

private var gps_location_driver : GpsPositionDriver;

 

 

When you want to start the simulator, call:

 

 

this.gps_location_driver = new GpsPositionDrive( this.gps_service );

this.gps_location_driver.Start();

 

 

Hope that helps.