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

  • SEARCH
  • Home
  • 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 7066645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:06:22+00:00 2026-05-28T05:06:22+00:00

i am developing app in Blackberry which have GPS Functionality. so first i want

  • 0

i am developing app in Blackberry which have GPS Functionality. so first i want to get Current latitude and longitude but it will dipslay like time out while waiting for GPS loaction. Below in my code for getting lat and long of current location.

public class LocationScreen extends MainScreen 
{
      public LocationScreen() 
      {
        super();
        final LabelField lfLocation = new LabelField();
        new Thread()
        {
          public void run() 
          {
            LocationHandler lh = new LocationHandler();
            final String msg = "Long: " + lh.getCurrentLongitude() + ", Lat: " + lh.getCurrentLatitude();

            Application.getApplication().invokeLater(new Runnable() 
            {
              public void run() 
              {
                lfLocation.setText(msg);
                add(new LabelField("Lat and Long=="+msg));
              }
            });
          }
        }.start();
        this.add(lfLocation);
      }
    }

**Second Class**

public class LocationHandler 
{
  private LocationProvider locationProvider;
  private Location currentLocation;
  public LocationHandler()  
  {
    try 
    {
      locationProvider = LocationProvider.getInstance(null);
      currentLocation = locationProvider.getLocation(60);
    }
    catch (final Exception e) 
    {
      Application.getApplication().invokeLater(new Runnable() 
      {
        public void run() 
        {
          Status.show(e.getMessage());
        }
      });
    }
  }
  public double getCurrentLongitude() 
  {
    if(currentLocation != null)
      return currentLocation.getQualifiedCoordinates().getLongitude();
    return -1;
  }
  public double getCurrentLatitude() 
  {
    if(currentLocation != null)
      return currentLocation.getQualifiedCoordinates().getLatitude();
    return -1;
  }

what i am doing mistake in my code please help me.
Thanx in advance.

  • 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-05-28T05:06:22+00:00Added an answer on May 28, 2026 at 5:06 am

    Make simple Thread and write down below code in run method .

    private BlackBerryCriteria blackBerryCriteria = null;
    private BlackBerryLocation blackBerryLocation = null;
    private BlackBerryLocationProvider blackBerryLocationProvider = null;
    double lat = 0.0;
    double lng = 0.0;
    
    blackBerryCriteria = new BlackBerryCriteria();
    
        if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_CELLSITE)) 
        {
            blackBerryCriteria.setMode(GPSInfo.GPS_MODE_CELLSITE);
        }
        else if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST)) 
        {
            blackBerryCriteria.setMode(GPSInfo.GPS_MODE_ASSIST);
        }
        else if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_AUTONOMOUS)) 
        {
            blackBerryCriteria.setMode(GPSInfo.GPS_MODE_AUTONOMOUS);
        }
        else 
        {
            blackBerryCriteria.setCostAllowed(true);
            blackBerryCriteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
        }
    
    try {
                blackBerryLocationProvider = (BlackBerryLocationProvider) BlackBerryLocationProvider.getInstance(blackBerryCriteria);
                blackBerryLocation = (BlackBerryLocation) blackBerryLocationProvider.getLocation(60);
    
                QualifiedCoordinates qualifiedCoordinates = blackBerryLocation.getQualifiedCoordinates();
    
                lat = qualifiedCoordinates.getLatitude();
                lng = qualifiedCoordinates.getLongitude();}catch(Exception e)
            {
                System.out.println("Error in location :"+e.toString());
                System.out.println("Error in location :"+e.getMessage());
            }
    

    Try this it working fine in my device using BIS.
    i hope it will help you ..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking into developing a small app to run on a blackberry which
I'm considering developing an app for Google App Engine, which should not get too
i am Developing app for Blackberry.in button click event i want to hide/invisible verticalFieldManager
I am developing Blackberry application. Every time when i want to test my app
I'm developing a BlackBerry app in Java and I have an Options class where
I'm developing a Java app for blackberry, in this app I have a login
I want to develop a chat app for BlackBerry. I did search, but found
Hi i am developing app in which there will be multiple tables in single
I'm developing an app for Blackberry on OS 5. I'm trying to have some
I'm developing an ActionScript 3.0 app for Blackberry Playbook. I have twelve images loaded

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.