LocationProvider, RenderingApplication

Hello

I have a problem with the location provider and rendering application.

My screen stretches screen and implements LocationListener and RenderingApplication.

I don't know where / what the problem is but at the start of the page to make I don't get updates of location more, even after the page is rendered.

I tried to put the location in the main UiApplication earpiece but always stop

Yes, I found one, I do not use listener location... I just create a class where I get the coordinates at the moment where I need it. I preferred with listener location but a reason, it did not work...

So just get the LocationProivder.getInstance (criteria); and if you return a valid coordinate use it... I have no better idea

Tags: BlackBerry Developers

Similar Questions

  • setPreferredTransportTypes for the LocationProvider

    Is there a way to setPreferredTransportTypes for the LocationProvider in 5.0?  I have problems with the connections on the company's intranet.

    It is not possible to define the route of transport for a LocationProvider.

    The first versions of BlackBerry device software 5.0 tried to use SDM first, then BIS_B.  This was changed in later 5.0 (and 6.0) versions to try to use BIS_B first, then MDS.

  • Different ways to reset the LocationProvider in the article?

    Hi guys.

    I'm confused about LocationProvider reset in the statutes.

    So, first of all:

    This article on:

    How to-detect when the GPS is no longer available and the moment reset the LocationProvider

    There are way to reset LocationProvider:

    Step 2: reset the LocationProvider

    Once the detection is complete, the next step is the LocationProvider reset. To do this, simply call reset() on LocationProvider instance, and then set either LocationListener null, or register a new LocationListener.

    It is just like in the code:

    locationProvider.reset ();

    locationProvider.setLocationListener (null, 0, 0, 0);
    locationProvider = null; I am not persuaded that this line.

    locationProvider.setLocationListener (new LocationListenerImpl(), 0, 0, 0);

    Second,

    This article on:

    What's – best practices for the design of GPS applications for smartphones BlackBerry running on CDMA Networks

    There is a code that LocationProvider everything like reset:

    provider.setLocationListener (null, 0, 0, 0);
    Provider.Reset ();
    Provider = null;
    Provider = LocationProvider.getInstance (criteria);
    provider.setLocationListener (new LocationListenerImpl (), interval, timeout, maxAge);

    What is the correct code?  First or second?

    Please help me guys.

    Thanks in advance.

    If I was coding it again, I would

    provider.setLocationListener (null, 0, 0, 0);
    Provider.Reset ();
    Provider = null;

  • LocationProvider.getInstance returns a null value for the positioning of the cell PHONE location

    Hi guys.

    I'm having a problem trying to get a network of cells (MS basis) path to be able to work on my BlackBerry Bold 9000.

    Both assisted and Standalone GPS work (outside of course), but I'll try to find a way to position themselves inside the building.

    Here's what I'm going to put criteria:

    Criteria criteria = new Criteria();
    
    criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
    criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
    criteria.setCostAllowed(true);
    criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
    
    LocationProvider.getInstance(criteria); //<-- Returns null on real device
    

    When I run on a real device it gives me always null, when I do the same thing on a simulator, so this works:

    What I am doing wrong? I really need to find a way to make it work inside.

    Thanks for any input.

    Hey, Dominator,.

    I'll be real simple with you and try to make you save a LOT of time.

    Basically, cell tower positioning doesn't work out of the box on the Blackberry platform (except in a few configurations of rare device / carrier). So you can essentially throw the code you have above. If you need a place inside detection, you will need access to a database of celltowerId. These databases contain information from the Tower (Rad_error_nocontent, mnc, mcc, Lake) and its approximate location (lat/lng coordinates). This will give your application a rough estimate (less than a mile or two) from the current location of the device.

    Open source and professional databases are available. This is an open source database that runs on GSM networks (of course, he didn't 100% coverage of all the pylons). The biggest downfall is that it does not support CDMA (Sprint/Verizon) networks.

    http://openCellId.org

    You will find that most of the people on this forum are not very useful when it comes to cellTower information, positioning so you will need to research, research, research.

    Good luck

  • LocationProvider

    Hello

    I have problems with a locationprovider demo application that I'm writing.  The code will not be compiled in the

    to the point where I create a new locationprovider.  Can someone help me with what I'm doing wrong?

    Here is my code

    {

    Criteria = new Criteria();
           
    criteria.setHorizontalAccuracy (Criteria.NO_REQUIREMENT);
    criteria.setVerticalAccuracy (Criteria.NO_REQUIREMENT);
    criteria.setCostAllowed (true);
           
    criteria.setPreferredPowerConsumption (Criteria.POWER_USAGE_LOW);
           
           
    LocationProvider provider = LocationProvider.getInstance (criteria);
           
    LocationProvider provider = LocationProvider.getInstance (criteria);
           
    }

    I use these imports

    Net.rim.device.api.ui import. *;
    Net.rim.device.api.ui.component import. *;
    Net.rim.device.api.ui.container import. *;
    to import java.util.Enumeration;
    Import net.rim.blackberry.api.invoke.Invoke;
    Import net.rim.blackberry.api.invoke.MapsArguments;
    Javax.microedition.pim import. *;
    Javax.microedition.location import. *;

    The compiler is you say the problem:

    "exception undeclared javax.microedition.location.LocationException; must be captured or declared adjourned. "

    The best thing to do is to put the "getInstance" in a try/catch clause, because it may throw an exception.

    For example:

    LocationProvider provider = null;

    try {}

    Provider = LocationProvider.getInstance (null);

    } catch (Exception e) {}

    System.out.println ("Exception get the location provider:" + try ());

    }

    You will need to review the javadocs to see what exceptions can be thrown by a statement and how you treat them.

  • LocationProvider.getInstance always returns null

    I'm trying to run a slightly modified version of the application on a BlackBerry 7250 GPSDemo. As my device software is version 4.1, I use the BlackBerry JDE 4.1. No matter what are the parameters for the criteria, I pass in LocationProvider.GetInstance, I always return null. I can run google maps on this unit and get my location, so I'm assuming that the GPS is supported in this regard. Did anyone see any problem with code and/or information on the devices below?

    Wireless blackBerry 7250 (CDMA)

    v4.1.0.353 (Platfor 2.2.0.159)

    The kernel v3.8.3.7 encryption

    The microedition configuration: CLDC-1. 1

    Microedition profile: MIDP-2. 0

    Microedition JTWI Version: 1.0

    Microedition Media Version: 1.1

    Microedition PIM Version: 1.0

    Try
    {
    GpsReceiverCriteria criteria = new Criteria();
    gpsReceiverCriteria.setHorizontalAccuracy (Criteria.NO_REQUIREMENT);
    gpsReceiverCriteria.setVerticalAccuracy (Criteria.NO_REQUIREMENT);
    gpsReceiverCriteria.setCostAllowed (true);
    gpsReceiverCriteria.setPreferredPowerConsumption (Criteria.POWER_USAGE_LOW);
    gpsReceiverCriteria.setAddressInfoRequired (false);

    _locationProvider = LocationProvider.getInstance (gpsReceiverCriteria);
               
    If (_locationProvider is nothing)
    {
    Runnable ShowGpsLocationProviderNull1Dialog = new Runnable()
    {
    public void run()
    {
    Dialog.Alert ("Provider is null - HA: NR VA: NR CA:T PC:L");
    }
    };
    invokeLater (showGpsLocationProviderNull1Dialog);  Ask the event dispatcher thread to display the dialog box as soon as POSSIBLE
    }
       
    gpsReceiverCriteria.setHorizontalAccuracy (Criteria.NO_REQUIREMENT);
    gpsReceiverCriteria.setVerticalAccuracy (Criteria.NO_REQUIREMENT);
    gpsReceiverCriteria.setCostAllowed (false);
    gpsReceiverCriteria.setPreferredPowerConsumption (Criteria.POWER_USAGE_LOW);
    gpsReceiverCriteria.setAddressInfoRequired (false);

    _locationProvider = LocationProvider.getInstance (gpsReceiverCriteria);
               
    If (_locationProvider is nothing)
    {
    Runnable ShowGpsLocationProviderNull2Dialog = new Runnable()
    {
    public void run()
    {
    Dialog.Alert ("Provider is null - HA: NR VA: NR CA:F PC:L");
    }
    };
    invokeLater (showGpsLocationProviderNull2Dialog);  Ask the event dispatcher thread to display the dialog box as soon as POSSIBLE
    }

    _locationProvider = LocationProvider.getInstance (null);
               
    If (_locationProvider is nothing)
    {
    We would like to display a dialog box indicating that the GPS is not supported, but because that
    the event dispatcher thread has not been started yet, modal screens cannot be pushed on
    the battery in the display.  So delay the operation until the event dispatcher thread runs
    asking him to call the executable object following as soon as possible.
    Runnable showGpsUnsupportedDialog = new Runnable() {}
    public void run() {}
    Dialog.Alert ("No receiver GPS on this unit is available, exit...");
    System.Exit (1);
    }
    };
    invokeLater (showGpsUnsupportedDialog);  Ask the event dispatcher thread to display the dialog box as soon as POSSIBLE
    }
    on the other
    {
    only a single listener can be associated with a provider and point it comes to the same
    call, but with the value null, so, no need to cache the listener instance
    request an update every second
    _locationProvider.setLocationListener (new LocationListenerImpl(), _interval, 1, 1);
    retval = true;
    }
    } catch (LocationException) {}
    System.Err.println ("Failed to instantiate the object LocationProvider, exit...");
    System.Err.println (the);
    System.Exit (0);
    }

    Oops... sory. My dyslexia again out of in

    I think that the 7250 has no GPS function at all.

    Yet again, Google it didn't need because they have their own turn cells DB and web services to retrieve the "approximate" location

  • NullpointerException in LocationProvider Listenerthread

    Ive been hunting around the forum for some time for a solution to this problem but have no luck... Ive has developed an application that needs to monitor gps... positioning using the obvious locationprovider with independent criteria I do work... for the first 5 minutes at least... my debugging code shows me that the location is updated with the provider (added locationlistener) regularly and without any hickups... However after about 5 minutes or more (and yes it is compatible) I get a nullpointer exception... the use of the debugger in eclipse, it shows which is comes from LocationProvider ListenerThread.run line 644... Obviously I don't see what he does so that is where the headaches come... Here is my code (although not very complicated) that I use to make it all work... any input is useful, but ill keep working on it... If I'm missing something obvious please feel free to point me in the right direction (or link by the way) thank you...

    public class GPS implements LocationListener {
        private LocationProvider provider;
        private Location location;
        private WhereAreYouMainScreen mainscreen;
    
        public GPS(Criteria criteria,WhereAreYouMainScreen main) throws LocationException
        {
            this.provider=LocationProvider.getInstance(criteria);
            this.provider.setLocationListener(this, -1, -1, -1);
            this.mainscreen=main;
    
        }
        public Location getLocation(RichTextField rich)
        {
            return this.location;
        }
        public void locationUpdated(LocationProvider provider, Location location) {
            System.out.println("Location updated new location: "+location.getQualifiedCoordinates().getLatitude()+" "+location.getQualifiedCoordinates().getLongitude());
            this.mainscreen.LocationUpdated(location);
            this.location=location;
    
        }
        public void providerStateChanged(LocationProvider provider, int newState) {
            System.out.println("Provider state changed");
    
        }
    

    OK, so I think that Ive solved the problem... I tried to use if(location!=null), but kept program hooked to this place... looking through the class location, I found isvalid()... it seems to work but I can't explain why the provider would say it is avaailable I check the supplier State to inside the locationUpdated() method and the provider is always avaiable... Here is my code if n e one encounters this problem, I hope this helps...

    public void locationUpdated(LocationProvider provider, Location location) {
            System.out.println("LOcation updated check validity");
    
            if(location.isValid())
            {
                System.out.println("New Valid Location: "+location.getQualifiedCoordinates().getLatitude()+" "+location.getQualifiedCoordinates().getLongitude());
            this.mainscreen.LocationUpdated(location);
            return;
    
            }
            System.out.println("Error Location was NULL");
            int i=provider.getState();
            if(i==LocationProvider.AVAILABLE)
            {
                System.out.println("Weird provider was avaialable");
            }
            if(i==LocationProvider.OUT_OF_SERVICE)
            {
                System.out.println("Provider out of servcie");
            }
            if(i==LocationProvider.TEMPORARILY_UNAVAILABLE)
            {
                System.out.println("Provider temp unavailable");
            }
    
        }
    
  • Listener GPS problem

    Hi people,

    In collaboration with 4.2.1 on the 8800 Simulator.  My application is currently composed of two separate applications, app UI to obtain/view the information and a 'replication' application that communicates with our backend. I want to be able to include location on request of the user data (in the application user interface) and once it is updated, have replication app send it to the server. I have this work especially to my satisfaction, but the following problem: when I close the application user interface, any incomplete GPS please never finished. It seems that my LocationListener is not registered, or maybe the listener Thread is killed the closure of the part of the user interface. I don't expect that the instance is stored in the runtimestore and the object that is saved as the listener is always valid. Here's how I set it up:

    App of the user interface, the following is performed from a menu, click:

                GPSUpdater gps = GPSUpdaterFactory.getGPSUpdater();            gps.getGPSData(row, GPSUpdater.CHECK_IN);
    

    Replication App: (cut a lot of independent code)

    class ReplicationManagerImpl implements LocationListener{    private GPSUpdater mGPSUpdater;
    
        ReplicationManagerImpl()    {        mGPSUpdater = GPSUpdaterFactory.getGPSUpdater();        mGPSUpdater.setListener(this);    }
    
        public void locationUpdated(LocationProvider provider, Location location)    {        mGPSUpdater.newLocationReceived(location);    }
    
        public void providerStateChanged(LocationProvider provider, int newState)    {        //Not worried about this    }}
    

    GPSUpdater:

    public class GPSUpdater{    private Vector mUpdates;    private LocationProvider mProvider;    private Location mLocation;    private LocationListener mListener;    private Boolean isAcquiring;    private int mCounter;
    
        private static final int MAX_RETRIES = 10;    public static final int CHECK_IN = 0;    public static final int CONFIRM = 1;
    
        private static class UpdateData    {        private DataRow suRow;        private int updateType;        private long timeStamp;    }
    
        GPSUpdater()    {        Criteria criteria = new Criteria();        criteria.setHorizontalAccuracy(50);        criteria.setVerticalAccuracy(50);        criteria.setCostAllowed(false);        try        {            mProvider = LocationProvider.getInstance(criteria);            if (mProvider.getState() == LocationProvider.OUT_OF_SERVICE)            {                SubsystemLog.log("GPS actions not supported", EventLogger.ALWAYS_LOG);            }        }        catch (LocationException lEx)        {            SubsystemLog.log("Error creating LocationProvider in GPSUpdater: " + lEx.getMessage(), EventLogger.ERROR);        }        mUpdates = new Vector();        mLocation = null;        isAcquiring = Boolean.FALSE;        mCounter = 0;    }
    
        public void setListener(LocationListener listener)    {        mListener = listener;    }
    
        public void getGPSData(DataRow row, int updateType)    {        long timestamp = System.currentTimeMillis();        if (((mLocation != null) && (mLocation.isValid()) && (mLocation.getTimestamp() > timestamp - 60000)) || (mProvider == null) || (mProvider.getState() == LocationProvider.OUT_OF_SERVICE))        {            UpdateRow(row, updateType, timestamp);        }        else        {            UpdateData update = new UpdateData();            update.row = row;            update.updateType = updateType;            update.timeStamp = timestamp;
    
                synchronized(mUpdates)            {                mUpdates.addElement(update);            }
    
                synchronized(isAcquiring)            {                if (!isAcquiring.booleanValue())                {                    mProvider.setLocationListener(mListener, 5, 5, -1);                    isAcquiring = Boolean.TRUE;                }            }        }    }
    
        public void newLocationReceived(Location location)    {        if ((location == null) || (!location.isValid()) && (mCounter < MAX_RETRIES))        {            mCounter++;            return;        }
    
            mCounter = 0;        mLocation = location;        SubsystemLog.log("Acquired co-ordinates: " + Double.toString(location.getQualifiedCoordinates().getLatitude()) + "," + Double.toString(location.getQualifiedCoordinates().getLongitude()), EventLogger.DEBUG_INFO);
    
            Database db = DataSystemFactory.getDataSystem().openDatabase(DBSchema.NAME);        Object syncObject = db.getSyncObject();
    
            synchronized(syncObject)        {            while (mUpdates.size() > 0)            {                UpdateData update = (UpdateData)mUpdates.elementAt(0);                UpdateRow(update.row, update.updateType, update.timeStamp);                mUpdates.removeElement(update);            }        }        db.commitAndNotify();
    
            synchronized(isAcquiring)        {            provider.setLocationListener(null, -1, -1, -1);            isAcquiring = Boolean.FALSE;        }    }
    
        private void UpdateRow(DataRow suRow, int updateType, long timeStamp)    {        //wrapper class to allow persisting double values        DBDouble latitude = new DBDouble();        DBDouble longitude = new DBDouble();
    
            if (mLocation != null && mLocation.isValid())        {            latitude.setDouble(mLocation.getQualifiedCoordinates().getLatitude());            longitude.setDouble(mLocation.getQualifiedCoordinates().getLongitude());        }        else        {            latitude.setDouble(0.0);            longitude.setDouble(0.0);        }
    
            //store data here    }
    
    }
    

    GPSUpdaterFactory:

    public abstract class GPSUpdaterFactory {    private static final long ID = ;
    
        public static final GPSUpdater getGPSUpdater()    {        Object o;        GPSUpdater gpsUpdater = null;        RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();        synchronized (runtimeStore)        {            o = runtimeStore.get(ID);            if (o != null)            {                if (o instanceof GPSUpdater)                {                    gpsUpdater = (GPSUpdater)o;                }            }            if (gpsUpdater == null)            {                gpsUpdater = new GPSUpdater();                runtimeStore.put(ID, gpsUpdater);            }        }        return gpsUpdater;            }}
    

    Any suggestions are greatly appreciated.

    Thank you

    Mike

    Notice that the menu close item also called System.exit.

    In this case the application would stop receiving updates following the call of output.  To work around this problem, you can call Application.requestBackground.  This moves the application in the background, where it can continue to operate.  Once you have your final fix application can call System.exit to close itself.

  • getURL() BrowserContentBaseImpl

    Hello world

    I want to get the URL currently user has opened in the browser, in a variable. I tried something like that...

    BrowserContentBaseImpl bcbi = (BrowserContentBaseImpl) RenderingSession.getNewInstance () .getBrowserContent (...)

    Here I'll need a few parameters, such as objects

    HttpConnection, RenderingApplication and sometimes flags or in some cases the URL it self.

    Please can one tell me where to find the solution if it already exists. Or how to address this problem?

    You can't get the URL of the page that the user has opened in the browser. It would be a privacy hole.

    The getURL() method you are looking at is used when you integrate a browser field in your own application. If you do this (instead of using the default system browser), you can get the URL, but you also have to provide the content of the URL anyway.

  • Calculation of the distance of the location GPS provider

    I'm looking to develop an application of GPS based location by saving a LocationListener with the LocationProvider, I need to be able to calculate the distance between two cooridinates.

    The Coordinates () .distance method doesn't seem to work, also responds to 0.

    I saw and distance example where speed and range were used to calculate, but I was wondering is this reliable?

    An alternative is to calculate the distance between two coordinates using the Haversine formula, the java class Math in Blackberry JDE however does not have the required operation atan2. Anyone know of any alternative?

    Thank you

    Dave

    In my experience, the distance calculation works.  What results are you seeing?  Are you sure these two places are valid?

    I would not use speed and interval unless there is no other choice, or that the interval was small.

    The quesiton on atan was invited to this forum, have a search for her.  Here is an answer:

    BB has no ACON, ATAN, ASIN

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=142&query.ID=2195...

  • setLocationListener?

    Hello

    I created a simple application that gets the current GPS position and displays on the screen, once the user presses the button "take place. Now I use a listener action... but the screen contains with long and lat updates on intervals. I don't want to do. I just want to get along and the lat once and display on the screen when the button is clicked.

    Which method should be used to return the values that I don't need only once?

    Any help will be appreciated.

    Concerning

    Wes

    Try this

    class FieldListener implements {FieldChangeListener}
    longitude double private;
    Private double latitude;

    ' Public Sub fieldChanged (field field, int context) {}
    try {}
    final LocationProvider lp = LocationProvider.getInstance (null);
    If (lp! = null) {}
    lp.setLocationListener (new GetCoordinates(), interval, 1,
    // 1);
    New Thread (new Runnable() {}
    public void run() {}
    int timeout = - 1;
    try {}
    A place = lp.getLocation (timeout);

    Longitude = location.getQualifiedCoordinates)
    . getLongitude();
    Latitude = location.getQualifiedCoordinates () .getLatitude ();
    } catch (LocationException e) {}
    Generative TODO catch block
    e.printStackTrace ();
    } catch (InterruptedException e) {}
    Generative TODO catch block
    e.printStackTrace ();
    }

    }
    ({. start()});
                        
    } else {}
    Dialog.Alert ("GPS NOT supported!");
    }
    } catch (LocationException e) {}
    System.out.println ("LocationException:" + try ());
    } catch (Exception e) {}
    System.out.println ("Exception:" + try ());
    }
    }
    }

    Let me know if it solves your problem

    Thank you

    Ankit

  • Supports the 8830 World Edition GPS functions?

    Hi guys.

    I am facing some problem GPS. I need to test my app on Simulator for the BB 8830 World edition.

    But this Simulator supports the GPS (using JDE 4.5.0). I read the topic on smart phones with GPS from herecapabilities.

    The reason for writing this post is: my friend's 8830 world edition and it works at my request.

    Then my application detects "no GPS device.

    To detect the GPS, using following code:

    If (LocationProvider.GetInstance (null) == null) {}

    This device has no GPS

    } else {}

    GPS is ok.

    }

    Is it really unit no GPS?

    What is the best way to detect the GPS features?

    Please share with me any source code of example concerning the detection of GPS capabilities.

    Thank you guys.

    The 8830 supports only "assisted" mode on the Verizon network, which you can't access without EDP information.

    See your other thread on the subject, where I answered your question with references to the relevant KB articles.

  • Current GPS location

    Hello

    To get the current GPS location, I tried with this code, but doesn't seem to work

     private void testGPSLocation(){
            Thread t = new Thread(new Runnable() {
    
                public void run() {
                    //GPS Location
                    try{
                        LocationProvider provider = LocationProvider.getInstance(null);
                        Location loc = provider.getLocation(180);
                        Coordinates self = loc.getQualifiedCoordinates();
                        if (self != null)
                        {
                            double longitude = self.getLongitude();
                            double latitude = self.getLatitude();
                            System.out.println("longitude "+ longitude);
                            System.out.println("latitude "+ latitude);
                        }
                    }catch(Exception ex){
                        ex.printStackTrace();
                        System.err.println(ex.toString());
                    }
                }
            });
    
            t.run();
       }
    

    I tried to run GPSDemo of the samples provided by BlackBerry... but still he always gives the Longitude/Latitude/Altitude values by '0 '. I am running on BlackBerry 9530/9630. Are there settings need to be changed?  There is a possibility to enter the name of the server and I put my PC (localhost)... but still the same address. Any help on this would be appreciated.

    Thank you

    -DESTREEZ

    Large.

    Please check the thread "resolved".

  • providerStateChanged... again

    Never get called the providerStateChanged method?

    I've disabled GPS and disabled location caregiver.

    Still my app still does not call the method in the class that implements LocationListener.

    Thanks for the suggestion. That will keep in reserve, don't really like to do workaround when it appears something like cut and dry that the method is never executed. I would like to use the providerStateChanged method as it was designed/intended.

    Are you aware of what is a bug or I use it wrong?

    Thank you.

    BUG - see thread http://supportforums.blackberry.com/t5/Java-Development/locationProvider-getLocation-re-creating/m-p...

    Created the: March 25, 10 15:55 updated: 22 Apr 10 15:33
    Return the search of
    Number 1 of 2 issue (s)
  • GPS latitude and longitude are not when no signal

    Hello

    I am buliding a BB 9700 GPS application. I am able to get the latitude and longitude through cellTower (using the Service Provider signal), but I am unable to get the latitude and longitude when there is no signal. I tried the criteria to false, but the lattude and longitude do not come.

    Please find the code below

    private LocationProvider _provider;
    private Criteria _criteria;
    boolean deviceReciever,cellSignal;
    
    String longitude, latitude,altitude,speed;
    
    private void FixLocation()
    {
          resetProvider();
          /** Initialize Criteria and LocationProvider instances. */
    
          deviceReciever = true;//receiving lattitude and longitude to phone gps reciever
          cellSignal; = false;//Disabling ph signals
    
          setupCriteria();
          createLocationProvider();
    
                   if(_provider!=null){
    
                      try{
                       _location = _provider.getLocation(5);
                     locationUpdated(_provider, _location);
                     }catch(InterruptedException e){
                            //log(e.getMessage());
                            System.out.println("Exception called --->"+e);
                       }catch(LocationException e)
                       {
                               //log(e.getMessage());
                               System.out.println("Exception called --->"+e);
                       }
                       /*-->
                       try
                       {
                            System.out.println("babaji");
                            System.out.println("The _interval="+_interval);
                            _interval = -1;
                            _provider.setLocationListener(this, _interval, 10, 20);
                       }
                       catch(Exception e)
                       {
                           System.out.println("Exception called-->"+e);
                       }
                       */
                   }
    
           }
    
        private void resetProvider()
        {
            if (_provider != null)
           {
              _provider.setLocationListener(null, 0, 0, 0);
              _provider.reset();
              _provider = null;
            }
         }
    
          private void setupCriteria()
          {
                _criteria = new Criteria();
                if( deviceReciever == true )
                {
                    _criteria.setCostAllowed(false);
    
                }
               else if( cellSignal == true )
                {
    
                    _criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
                    _criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
                    _criteria.setCostAllowed(true);
                    _criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
                }
           }
    
        private void createLocationProvider()
       {
                    /**
                 * Initialize _provider using _criteria.
                    */
                try
                {
                     _provider = LocationProvider.getInstance(_criteria);
                }
                catch (LocationException e)
                {
    
               }
          }
    
         public void locationUpdated(LocationProvider provider, Location location)
        {
                 if (location != null && location.isValid())
                 {
    
                      QualifiedCoordinates coordinates = location
                                        .getQualifiedCoordinates();
    
                        speed = Float.toString(location.getSpeed());
                        longitude = Double.toString(coordinates.getLongitude());
                        latitude = Double.toString(coordinates.getLatitude());
                        altitude = Float.toString(coordinates.getAltitude());
    
                        System.out.println("Longitude --->"+coordinates.getLongitude());
                        System.out.println("Latitude---->"+coordinates.getLatitude());
                        System.out.println("Altitude->"+coordinates.getAltitude());
                    }
    
         }
    

    The longitude and latitude are coming as null always if we I'm reciving the gps via the mobile gps receiver. If the signal of the mobile service provider then uses the lang and lat come.

    I don't want to use the service provier signal for lattitude and longitude.

    Please suggest me the error I made in the above code and assistance.

    Thanking you

    Standalone GPS works best outdoors, with a clear view of the sky.  At the very least, near a window.

    You can experiment with the timeout.

    (If these answers answer your question, please mark the thread as solved.  (Thank you).

Maybe you are looking for