Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:27:26+00:00 2026-06-04T04:27:26+00:00

In simulator my gps code work fine. But when I install my app in

  • 0

In simulator my gps code work fine. But when I install my app in device I can’t get current latitude and longitude.

When I send lat long from simulator it get proper lat long which is send through simulator. I don’t know why is not working in device?

I have already enable from Option > Advance option > gps > gps servce and set Location ON.
Is there any other setting for get current location in device?

private boolean currentLocation() {  
    boolean retval = true;  
   try {  
       LocationProvider lp = LocationProvider.getInstance(null);  
       if (lp != null) {  
            lp.setLocationListener(new LocationListenerImpl(), interval, 1, 1);  
        } else {  
            // GPS is not supported, that sucks!  
            // Here you may want to use UiApplication.getUiApplication() and post a Dialog box saying that it does not work  
            retval = false;  
        }  
    } catch (LocationException e) {  
        System.out.println("Error: " + e.toString());  
    }  

    return retval;  
}  

private class LocationListenerImpl implements LocationListener {  
    public void locationUpdated(LocationProvider provider, Location location) {  
        if (location.isValid()) {  
            heading = location.getCourse();  
            longitude = location.getQualifiedCoordinates().getLongitude();  
            latitude = location.getQualifiedCoordinates().getLatitude();  
            altitude = location.getQualifiedCoordinates().getAltitude();  
            speed = location.getSpeed();  

            // This is to get the Number of Satellites  
            String NMEA_MIME = "application/X-jsr179-location-nmea";  
            satCountStr = location.getExtraInfo("satellites");  
            if (satCountStr == null) {  
                satCountStr = location.getExtraInfo(NMEA_MIME);  
            }  

            // this is to get the accuracy of the GPS Cords  
            QualifiedCoordinates qc = location.getQualifiedCoordinates();  
            accuracy = qc.getHorizontalAccuracy();  
        }  
    }  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:27:26+00:00Added an answer on June 4, 2026 at 4:27 am

    Try this code

    Thread thread = new Thread(new Runnable() {
            public void run() {
                bCriteria = new BlackBerryCriteria();
                if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_CELLSITE)) {
                    bCriteria.setMode(GPSInfo.GPS_MODE_CELLSITE);
                } else if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST)) {
                    bCriteria.setMode(GPSInfo.GPS_MODE_ASSIST);
                } else if (GPSInfo
                        .isGPSModeAvailable(GPSInfo.GPS_MODE_AUTONOMOUS)) {
                    bCriteria.setMode(GPSInfo.GPS_MODE_AUTONOMOUS);
                } else {
                    bCriteria.setCostAllowed(true);
                    bCriteria
                            .setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
                }
    
                try {
                    bProvider = (BlackBerryLocationProvider) BlackBerryLocationProvider
                            .getInstance(bCriteria);
                    if (bProvider != null) {
                        bProvider.setLocationListener(new handleGPSListener(),
                                -1, -1, -1);
                        try {
                            bLocation = (BlackBerryLocation) bProvider
                                    .getLocation(60);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
    
    
                    }
                } catch (LocationException lex) {
    
                    lex.printStackTrace();
                    return;
                }
            }
        });
        thread.start();
    

    then implement Location Listener in the class

    public class handleGPSListener implements LocationListener {
        public void locationUpdated(LocationProvider provider, Location location) {
            if (location.isValid()) {
    
    
            }
        }
    
        public void providerStateChanged(LocationProvider provider, int newState) {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app works fine in the simulator but when I run it on my
I'm writing an app that needs to get the longitude and latitude from the
i need to get latitude and longitude using gps on blackberry. When i check
My project worked perfectly on simulator+device, but now, after upgrading to lion os and
I'm working in the simulator and my app is GPS enabled. So naturally I
while test in simulator it work very well , while in device it raise
How to change or reset an iPhone simulator device ID?
On the Mac I got the iPhone Simulator but under Windows and Linux enviroments
Its working perfectly in the iphone simulator. But not in the ipad simulator. I
I'm developing an app that uses iOS4 features (like MFMessageComposeViewController), but I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.