BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-24-2009, 07:55 PM   #1
GasBot
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: Pearl
PIN: N/A
Carrier: T-Mobile
Posts: 22
Default Problem getting GPS coordinates

Please Login to Remove!

Here's the code I'm using trying to get GPS coordinates. It seems like every time it times out and ends up returning 0 for both the latitude and longitude even though I've both set a location in my Simulate -> GPS Location.. window and gone into the Options -> Advanced Options -> GPS -> Refresh Location.

In my main application class this function gets called from a button.
Code:
public void GetCurrentLocation() {
        Criteria ct = new Criteria();
        //ct.setAddressInfoRequired(false);
        //ct.setAltitudeRequired(false);
        ct.setCostAllowed(true);
        ct.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
        ct.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
        ct.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
        //ct.setPreferredResponseTime(10000);
        //ct.setSpeedAndCourseRequired(false);
        
        try {
            myLP = LocationProvider.getInstance(ct);
            myLP.setLocationListener(new myLocListener(this), -1, -1, -1);
        } catch (Exception ex) {
            return;
        }
    }

public void GotLocation(Location myLoc) {
        if(myLoc != null) {
            QualifiedCoordinates qc = myLoc.getQualifiedCoordinates();
            //Call webservice here.
        }
    }
In the myLocListener.java
Code:
package net.gasbot;

import javax.microedition.location.*;

public class myLocListener implements LocationListener
{
    GasBotScreen gb;
    
    public myLocListener(GasBotScreen gb)
    {
        this.gb = gb;
    }
    
    public void locationUpdated(LocationProvider provider, Location location)
    {
        QualifiedCoordinates qc = location.getQualifiedCoordinates();  //I set a breakpoint here, but it rarely gets called, and when it does, the coordinates are both 0.
        provider.setLocationListener(null, 0, 0, 0);
        gb.GotLocation(location);
    }

    public void providerStateChanged(LocationProvider provider, int newState)
    {
        
    }
}
Can someone please let me know what I'm doing wrong? I'm setting the listener to null after it gets an updated location as I only need it once.

I've also tried using the .getLocation(-1) and it doesn't work either. Is there something wrong with my simulator? Or just something wrong with my code?
Offline  
Old 03-24-2009, 09:57 PM   #2
GasBot
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: Pearl
PIN: N/A
Carrier: T-Mobile
Posts: 22
Default

Nevermind, got it working. Thanks for all the replies!
Offline  
Old 03-25-2009, 04:45 AM   #3
hippocamp software
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Default

you expect a reply and a solution within 2 hours you sarcastic so-and-so?
Offline  
Old 03-25-2009, 09:40 AM   #4
GasBot
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: Pearl
PIN: N/A
Carrier: T-Mobile
Posts: 22
Default

Quote:
Originally Posted by hippocamp software View Post
you expect a reply and a solution within 2 hours you sarcastic so-and-so?
A reply, maybe not a solution. But the official BlackBerry support forums had several replies before this one despite me posting it there an hour later than here.
Offline  
Old 03-25-2009, 09:45 AM   #5
zechariahs
Thumbs Must Hurt
 
Join Date: Nov 2008
Location: Sioux Falls, SD
Model: 9530
PIN: N/A
Carrier: Verizon Wireless
Posts: 65
Default

I think editing the first response to your post was an abuse of the edit feature.
__________________
Handspring >> Palm >> BB Pearl >> BB Storm

Tumblog: http://www.geekkink.com
Blog: http://www.zechariahs.org/blog
Offline  
Old 03-25-2009, 09:51 AM   #6
hippocamp software
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Default

i'm just shocked and surprised that the official developer forum would be quicker than here!
Offline  
Old 03-25-2009, 10:39 AM   #7
GasBot
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: Pearl
PIN: N/A
Carrier: T-Mobile
Posts: 22
Default

Quote:
Originally Posted by hippocamp software View Post
i'm just shocked and surprised that the official developer forum would be quicker than here!
Honestly, I am shocked. Usually I get more help from enthusiast websites like these than the corporate run forums.
Offline  
Closed Thread



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


New In Box JOHNSON CONTROLS F61KB-11C Water Flow Switch picture

New In Box JOHNSON CONTROLS F61KB-11C Water Flow Switch

$49.50



New Johnson Controls M300MJ Control Module Addressable FREE FAST SHIPPING picture

New Johnson Controls M300MJ Control Module Addressable FREE FAST SHIPPING

$78.00



JOHNSON CONTROLS V46AC-1C WATER REGULATING VALVE. 3/4

JOHNSON CONTROLS V46AC-1C WATER REGULATING VALVE. 3/4" FNPT. 70-260 PSI.

$95.99



Johnson Controls NSB8BTN240-0 Thermostats White Two years old, 20 available picture

Johnson Controls NSB8BTN240-0 Thermostats White Two years old, 20 available

$95.00



Johnson controls Map-1810 picture

Johnson controls Map-1810

$525.00



Johnson Controls Nsb8btn141-0 Network Sensor,No Display,White,No Logo picture

Johnson Controls Nsb8btn141-0 Network Sensor,No Display,White,No Logo

$120.99







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