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


National Instruments Mainframe Chassis - NI-PXIe-1071 w/Warranty picture

National Instruments Mainframe Chassis - NI-PXIe-1071 w/Warranty

$690.00



Chroma 6312A DC Electronic Load Mainframe **FOR PARTS ONLY, POWERS ON** picture

Chroma 6312A DC Electronic Load Mainframe **FOR PARTS ONLY, POWERS ON**

$150.00



Hewlett Packard HP 70001A Mainframe Chassis Industrial Unit HP70000 System  picture

Hewlett Packard HP 70001A Mainframe Chassis Industrial Unit HP70000 System

$26.99



Agilent E1301B Mainframe  9-slots with multimeter, totalizer, and relay muxes picture

Agilent E1301B Mainframe 9-slots with multimeter, totalizer, and relay muxes

$200.00



NEWPORT 8800 PHOTONICS TEST SYSTEM MAINFRAME picture

NEWPORT 8800 PHOTONICS TEST SYSTEM MAINFRAME

$499.99



National Instruments NI PXI-1044 Chassis 14-Slot PXI Mainframe 189105E-01 Rev 01 picture

National Instruments NI PXI-1044 Chassis 14-Slot PXI Mainframe 189105E-01 Rev 01

$199.99







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