BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-06-2012, 04:34 PM   #1
hananghabour
New Member
 
Join Date: Nov 2012
Model: 7100t
PIN: N/A
Carrier: 3g
Posts: 1
Default Trying to code and posted in the wrong place

Please Login to Remove!

hi any one here help me plz i am beginging in blackberry development i want to calculate distance when i drive my car to stop . my code get latitude , logitude , speed and show map correctly but temporary distance = 0
this is the code
public LocationHandler(LocationMainScreen screen) {
this.screen = screen;
}

public Coordinates[] getCoordinateHistory() {
Coordinates[] coordinates = new Coordinates[coordinateHistory.size()];
coordinateHistory.copyInto(coordinates);
return coordinates;
}

public void locationUpdated(LocationProvider provider, Location location) {
QualifiedCoordinates qualifiedCoordinates = location.getQualifiedCoordinates();

screen.setLocation(qualifiedCoordinates.getLongitu de(), qualifiedCoordinates.getLatitude());

String message = "Successfully got location at ";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
message += simpleDateFormat.format(new Date(location.getTimestamp()));

if (coordinateHistory.size() > 0) {
Coordinates lastCoordinates = (Coordinates)coordinateHistory.lastElement();
message += "\nDistance from last update: " + lastCoordinates.distance(qualifiedCoordinates);
}

coordinateHistory.addElement(qualifiedCoordinates) ;
//--------------------------------------------------------

public void run() {
Criteria csCriteria = new Criteria();
csCriteria.setHorizontalAccuracy(Criteria.NO_REQUI REMENT);
csCriteria.setVerticalAccuracy(Criteria.NO_REQUIRE MENT);
csCriteria.setCostAllowed(true);
csCriteria.setPreferredPowerConsumption(Criteria.P OWER_USAGE_LOW);

Criteria criteria = new Criteria();
criteria.setVerticalAccuracy(50);
criteria.setHorizontalAccuracy(50);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POW ER_USAGE_HIGH);

try {
screen.setMessage("Getting location...");
LocationProvider provider = LocationProvider.getInstance(criteria);
Location location = provider.getLocation(-1);

locationUpdated(provider, location);
if (periodicUpdates) {
// Update every 3 minutes
provider.setLocationListener(this, 180, -1, 10);
}
} catch (LocationException e) {
screen.setMessage("LocationException occurred getting location: " + e.getMessage());
} catch (InterruptedException e) {
screen.setMessage("InterruptedException occurred getting location: " + e.getMessage());
}
}
Offline  
Old 11-06-2012, 08:56 PM   #2
daphne
BBF Spam Killer Moderator
 
daphne's Avatar
 
Join Date: May 2007
Location: on a sunny beach
Model: Paspt
OS: 10.3.0.90
PIN: X1ZPY34K
Carrier: VZW but not for long
Posts: 9,176
Default Re: Trying to code and posted in the wrong place

Hi, I suggest you to check out the BlackBerry developer site. There is lots of info and even sample code.
https://developer.blackberry.com/
There are some developers here too that might be able to help.
__________________
Report spam text messages to 7726
#BlackBerry by choice
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Siemens 6SL3350-6TK00-0EA0 Siemens 6SL3 350-6TK00-0EA0 In Box Expedited Shipping picture

Siemens 6SL3350-6TK00-0EA0 Siemens 6SL3 350-6TK00-0EA0 In Box Expedited Shipping

$2762.81



Siemens Sinamics G120C Siemens 6SL3210-1KE23-2AF1 15KW new original sealed picture

Siemens Sinamics G120C Siemens 6SL3210-1KE23-2AF1 15KW new original sealed

$999.00



New In Box Siemens 6SL3130-6AE21-0AB1 SINAMICS S120 Module 6SL3 130-6AE21-0AB1 picture

New In Box Siemens 6SL3130-6AE21-0AB1 SINAMICS S120 Module 6SL3 130-6AE21-0AB1

$950.00



NEW SIEMENS 6SL3100-0BE25-5AB0 6SL3 100-0BE25-5AB0 S120 ACTIVE INTERFACE MODULE picture

NEW SIEMENS 6SL3100-0BE25-5AB0 6SL3 100-0BE25-5AB0 S120 ACTIVE INTERFACE MODULE

$3498.00



LOT OF 10 SIEMENS Q120DFN 20A DUAL AFCI/GFCI PLUG ON NEUTRAL BREAKER BRAND NEW picture

LOT OF 10 SIEMENS Q120DFN 20A DUAL AFCI/GFCI PLUG ON NEUTRAL BREAKER BRAND NEW

$416.99



LOT OF 10 SIEMENS QA115AFCN 15A AFCI PLUG ON NEUTRAL (NO PIGTAIL WIRE) NEW picture

LOT OF 10 SIEMENS QA115AFCN 15A AFCI PLUG ON NEUTRAL (NO PIGTAIL WIRE) NEW

$349.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.