getLocation question

My app uses the GPS demo code and seeks to acquire the location using cellsites.

I see two problems:

1. the code works on a 9550 Simulator, but does not return an a call from getLocation(-1) on a Bold 9700 device

2. when in setupCriteria that I use, the code is suspended on this line.

The pointers will be appreciated.

Thank you

//myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_CELLSITE);

The code looks like this:

private void setupCriteria(){
    _criteria = new Criteria();
    _criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
    _criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
    _criteria.setCostAllowed(true);
    _criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
    //myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_CELLSITE);
}

private void createLocationProvider(){
    try {
        _provider = LocationProvider.getInstance(myCriteria);
    } catch (LocationException e) {
        status("Error in location acquisition");
    }
}   

private void getSingleFix(){
    new Thread(){
        public void run(){
               resetProvider();
            setupCriteria();
            createLocationProvider();
            try {
            _location =_provider.getLocation(-1);         } catch (LocationException e) {
            status("Error in location acquisition");
            } catch (InterruptedException e) {
            status("Error in location acquisition");
            }

            if(_location!=null && _location.isValid()){
            QualifiedCoordinates coordinates = _location.getQualifiedCoordinates();
            double lat = coordinates.getLatitude();
            double longit = coordinates.getLongitude();
            latlong(lat, longit);               status(" ");
                log("In loc valid");

            } else{
                status("Error in location acquisition");
            }
        }
    }.start();
}
private void resetProvider(){
    if(_provider!=null){
        _provider.setLocationListener(null, 0, 0, 0);
        _provider.reset();
        _provider=null;
    }
}

public void locationUpdated(LocationProvider provider, Location location) {
    if(location!=null && location.isValid()){
        QualifiedCoordinates coordinates = location.getQualifiedCoordinates();
        double lat = coordinates.getLatitude();
        double longit = coordinates.getLongitude();
        latlong(lat, longit);
        status(" ");
    } else{
        status("Error in location acquisition");
    }
}

public void providerStateChanged(LocationProvider provider, int newState) {
        /**
         * not implemented. For more information on how to implement this method please
         * refer to the BlackBerry Developer Knowledge Base Articles.
         */

}

Try to set to high energy consumption and see if it works.

My GPS application appears to hang or throw a null pointer exception when I try to use Power Consumptin set to low temperature on my BB 9700.

() criteria.setPreferredPowerConsumption

Criteria.POWER_USAGE_HIGH);

Tags: BlackBerry Developers

Similar Questions

  • Wire Vs sleep Vs MDS Http connection Question

    Hello

    Here's my situation...

    I created a thread for background based on this article:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800660/How_To _...

    Here is my code:

    / * Thread that runs in the background * /.
    the final private class BackGroundThread extends Thread {}
    private static final int TIMER = 15; minutes
    Private boolean _stop = false;

    public synchronized void stop() {}
    _stop = true;
    }

    Private boolean isCoverageSufficient() {}
    If ((DeviceInfo.isSimulator ()) |)
    (RadioInfo.getState ()! = RadioInfo.STATE_OFF & (RadioInfo.getNetworkService () & RadioInfo.NETWORK_SERVICE_DATA)! = 0) & {CoverageInfo.isCoverageSufficient (CoverageInfo.COVERAGE_MDS))}
    Returns false; a Simulator or a real device with sufficient coverage
    }
    Returns false; real aircraft with insufficient coverage
    }

    public void run() {}
    CoverageInfo.addListener (new CoverageStatusListener() {}
    {} public void coverageStatusChanged (int newCoverage)
    {Switch (newCoverage)}
    box (CoverageInfo.COVERAGE_CARRIER):
    System.out.println ("COVERAGE_CARRIER");
    GPS.this.sendPoints ();
    break;
    box (CoverageInfo.COVERAGE_MDS):
    System.out.println ("COVERAGE_MDS");
    break;
    box (CoverageInfo.COVERAGE_NONE):
    System.out.println ("COVERAGE_NONE");
    break;
    }
    }
    });
               
    While (! _stop) {}
    GPS.this.getPoint (); try to get a GPS point
    Make sure the radio is on and there is the coverage of the data
    If (isCoverageSufficient()) {}
    GPS.this.sendPoints (); Send the _Dans table to the web server
    } else {/ / blackberry is out of coverage}
    GPS.this.storePoints (); store the table _Dans on blackberry
    }

    try {}
    Thread.Sleep(Timer*1000*60); pause the thread for a set number of minutes
    } catch (InterruptedException ie) {}
    System.Err.println ("Error:" + ie.toString ());
    }
    }
    }
    }

    The 'getPoint()' method to get a coordinate GPS using LocationProvider.getLocation ().

    The method 'sendPoints()' send the GPS coordinated to a web server using the HTTP connection:

    ...

    HttpConnection con = (HttpConnection) Connector.open (URL); Open the connection URL
    con.setRequestMethod (HttpConnection.POST); POST method
    con.setRequestProperty ("Content-Type", "application/x-www-formulaires-urlencoded");
    OutputStream out = con.openOutputStream (); display the results in a stream
    out. Write (Data.GetBytes ());
    int responseCode = con.getResponseCode (); Send data and receive the response code
    If (responseCode == HttpConnection.HTTP_OK) {}
    success
    }
    If (con! = null) con. Close; close the connection to the URL

    ...

    The "storePoints()" method simply store the GPS on the Blackberry Persistent Store when the BB is out of coverage.

    When the Blackberry is trying to send a GPS coordinate, but cannot because it is out of coverage, GPS data are stored on the Blackberry. My thread can sleep for 15 minutes before getting another coordinated GPS. If the BB is on the cover in the next interval of 15 minutes, the two coordinates are sent (the current and that (or those) that have been saved on the device).
    It works very well.

    However, now, I would put up a CoverageStatusListener so my GPS coordinates would be sent as soon as the BB is on the cover (and not wait for the next 15 minutes).
    I tried to "COVERAGE_MDS", but he never seems to have triggered... but gets "COVERAGE_CARRIER".
    I have a post on this here: http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=6076

    My question is on the wire. Actually here is called the 'sendPoints()' method:
    box (CoverageInfo.COVERAGE_CARRIER):
    System.out.println ("COVERAGE_CARRIER");
    GPS.this.sendPoints ();
    break;

    However, since my son sleeps, this method is not able to initiate a connection HTTP using MDS. I get an error in timeout after 2 minutes.

    I'm not an expert on the threads. I think I have all the necessary parts of the code... but I'm not sure about how to reorganize this.
    Can anyone help?

    Thank you!

    The network connection should be asked by a listener method.  Do not perform any operation or the heavy within a method of transformation of blocking listener.  Instead, you can create a new thread from the method which could then create the network connection to send your data.

  • LocationListener Vs getLocation GPS coordinates?

    Hello

    Just a quick question.

    I've read several times that the frequent difficulty, to use a LocationListener instead of lp.getLocation (repeated).

    What can be considered "frequent"?

    All the examples I've seen get GPS coordinates every 5 or 10 seconds.

    On my particular application, I do a lp.getLocation () every 15 minutes... but I want to change that to 5 or 10 minutes.

    I have two solutions work, I just would like to know which should I use for a fix every 5 or 10 minutes?  One who takes fewer resources battery and device?

    Thank you!

    I think that locationprovider would be nice in this case.

  • SharedObject created in AS2 RangeError leads "the supplied index is out of bounds" on call to getLocal.

    To ensure backward compatibility, I want the old AS2 Shared Objects to work in the new version of my application (in Flash Player 11.1 edition) AS3. For some reason, this isn't the case.

    The AS3 code is simple:

    var so: SharedObject = SharedObject.getLocal ("ExistingAS2SharedObject", "/");

    Sharing objects created in AS3 work perfectly well in this scenario, but they break when they were initially created in AS2, causing the RangeError 'the supplied index is out of range"on the line of code above. I don't have access to the AS2 code (I use CC), but it saves and loads fine in itself, as well, so there should be no other problems.

    I made sure set default AMF3 encoding, even if I think it is redundant. Are there known issues with AS3 objects shared AS3 to open? Do I need a different approach? Thoughts?

    Well, I worked on this bug for a few weeks. I am convinced that it is a problem with Flash 100%. Either way, here is the solution that I think solves the problem:

    -Use the AMF0 encoding. If you must use AMF3, set the "local playback security" in "allow local files only". Runs the file SWF in the browser, will replace so the problem is still, however, the question will be is no longer standalone.

    -Set the "local playback security' to the 'network allow only." It will not work otherwise.

    Other things that affect the bug include:

    -If the shared object created AS2 has been consulted by AS3 at any time, the bug will occur is no longer. I think that it is because it is converted to AMF3. This is likely to occur if you test under "Allow local files only", for example.

    -The bug may not be reproducible if Flash Player uses a lot of RAM. For example, I had the Flash Player using 1.4 GB of RAM, and the bug seemed to be stopped, misconduct, making it difficult for me to debug.

    -The bug behavior can change or not the SWF file is running in the debugger or standalone. I didn't test it enough to confirm however.
    -Put a try/catch around the code does not stop the shared destruction object. In addition, the code returns if a different shared object tries to access it. Everything behaves as expected if the bug does not occur in the first place.

    Some things that do not affect the bug include:

    -Other elements of code and the library loaded in the application do not affect the issue (assuming it is not intended to interfere with the code of course). The bug occurs also in the classes and SWC files.

    -Flash Player version and the version of the IDE have no effect on the bug, it seems.

    I hope this helps someone else in the future! And I hope that I never had to run into this bug once again, haha.

  • iOS 10 people record problem/question

    Hello

    I have a couple of "faces" in the issue of people who are coming in white, but acknowledged same 'face' of many times.  Is anyway to update it for photo comes actually?  At a few faces, I don't know that facial recognition found since it is coming from white.

    Hi JohnP007,

    Congratulations on your iPhone 7 more running iOS 10! I understand that some of your faces in the album of people pull up as a draft and you want to refresh. You can try to use the steps below to fix the faces on the thumbnails in albums.

    Difficulty faces and names mixed-up

    If you notice that there is a photo of someone in a collection that is poorly identified, you can remove it.

    1. Tap the person you want to remove in the album of people > select.
    2. Type Show done face to emphasize his face in every photo.
    3. Press on each photo that is not the person.
    4. Type > not this person.

    Hide people

    You can hide the people or groups that you don't want in your album of people.

    1. Open the album people and press Select.
    2. Touch the people you don't want to see.
    3. Click Hide.

    If you want to see the people that you have hidden, press on show hidden people.

    People in the Photos on your iPhone, iPad or iPod touch

    This should be corrected without delay faces. Please use the Apple Support communities to post your question. Good day.

  • Questions - and answers forgotten

    How to get my 'secret' answers to the questions that I have noted the way back when?

    If you forgot the answers to your questions of security of Apple ID - Apple Support

  • I can't reset the security questions. We received notice as below:

    Hello world

    I can't reset the security questions. We received notice as below:

    "Cannot reset Security Questions."

    We have insufficient information to reset your security questions. "

    Please help me as soon as possible! Thank you very much.

    Hello

    You will need to contact the Apple Support.

    The information is available here:

    Contact Apple for assistance with the security of the Apple ID - Apple Support accounts

    (I'm afraid that no one here can solve the problem for you - this is a user-based community).

  • Question of cloning for SSD upgrade on 12 Macbook Pro

    Previously, I did an upgrade to SSD on my Macbook Air to 2012 according to the instructions of JetDrive transcend. Basically connection via USB 3 and using Mac OS X to clear (and format) disc utilities new SSD, then restore again SSD and then remove the original 128 GB SSD and insert the new 480 GB SSD.  For about a month and so far without problem.

    Now I'm trying to 2012 Macbook upgrade my Pro partner (on 10.11.6).  I got a Crucial SSD MX300 to replace his HARD drive.  Crucial comes with (or recommend) Acronis software.  And a lot of the messages of the forum recommend Carbon Copy Clone.

    My question is if I can use the same method for the cloning of the HD as my Macbook Air (just restore disk of Mac OS X utilities)?  This time, I'm upgrading HARD drive and I don't know if something is different.  At the same time, if I got lucky the first time, I don't not ruin Macbook Pro my spouse this time.

    Thank you.

    Yes, you can use disk utility to clone your MBP wives, but unlike CCC, it will not clone the recovery and Partition.

  • Question about resolution movie downloads

    If I buy a movie at a certain resolution (780p for example), but I want more later re - download at a higher or lower resolution (SD or 1080 p), can I do so and how?

    Same question perhaps for music. Some of my songs have been bought before the latest Apple codecs.

    Any help is appreciated!

    THX!

    Once you have made a purchase on the iTunes store, you will see your purchased items in the menu under accounts bar > bought. You can simply select the item purchased and re-upload.

    With regard to the resolution of the film for films that are offered, and you select the resolution, you can download it again and select a different resolution. For movies that are available as separate download to SD, 780, or 1080 points, you would be limited to the original resolution you selected.

  • Why I can't ask questions.

    I just have a question.  I said that I can't ask questions.

    Do exactly what you did to make this post, but your question in there instead.

  • Cannot reset the Security Questions

    Hello my dear

    -J' forgot my account security questions, but I remember password

    And I'm changing my Security Questions, but show me this sentence

    "Cannot reset Security Questions."

    We have insufficient information to reset your security questions. "

    -I want to solve this problem as soon as possible if permitted

    You should contact the account of Apple security team. To join, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.

    (145081)

  • Bootcamp Windows 10 question

    Hi all

    Stumbled upon a problem, try to install Windows 10 an end 2014 27' iMac w/retina education runs Yosemite 10.10.5. Bootcamp is V 5.1.4. 32 GB, 3.5 ghz Intel I5. Disk of 1 TB of Fusion. Before you try this, I read the guide of Bootcamp to install windows, but also a number of other tutorials and forum messages about potential problems. This research, I learned that for EDU edition you must change the name of the file from Win10_1607_Education_English_x64.iso to Win10_1607_English_x64.iso. Apparently to have the former name of the file may cause OS X to not recognize the ISO. That fact I started Bootcamp, waited while the software downloaded and created a bootable USB key and partitioned my drive giving Windows 70 GB of space. After that, I got the message that my computer is restarts. Upon restarting, I got the black screen with the blue Windows logo and a spinning loading animation. After a few minutes, a blue screen with a message "Windows has encountered and error with computer and must restart," or something similar. He was pretty quick, so maybe it's not word for Word, but it was not a helpful post in terms of saying something specific. When the computer reboots, I am sent directly to OS X, though a bit slower than normal. I tried to restart with the flash drive to see if the installer would start up, no dice. Try now the Option key at startup, the flash player is not available. Went into my settings to see if I could change my startup on Win disk install USB, no luck it no more.

    Now for the question: How can I get the Windows installation again? What I have to start the process, and if so, what should I use Bootcamp to delete the partition that was created? I have re-run Bootcamp and the only option that is checked is the partition and start and install/uninstall windows and delete the partition.

    Thanks for the help.

    Perform the following two procedures

    Reset the management system (SCM) controller on your Mac - Apple Support

    How to reset the NVRAM on your Mac - Apple Support

    If you use a USB drive, not a USB flash drive, you will have problems. It is recommended to use a 8-16 GB USB2 flash drive.

    If the installation program is located on a USB Flash drive, stop your Mac, connect the USB key, restart and hold down the alt/option key and select the Windows icon in the USB port. This installs Windows in BIOS mode. If you click the start EFI icon, it will install using the EFI mode (faster). You may need to change the partition from MBR to GPT using GPT Fdisk.

  • Yahoo account question

    Yes, I understand these are the Apple support forums, but I don't know where else to ask this question and I thought some of you would have the answer to this question.

    I deleted my Yahoo account last week, but I've heard that the 500 million Yahoo accounts were hacked in 2014. I made my account in 2015. Im sure it is hacked since I made my account a year after the supposed hack, but if my account has been hacked and I deleted which would be safe?

    If your account did not exist in 2014, then it is has not been hacked. Removal of the guarantees it will not be new since there was more pirate. Normally, at least the hackers got access to more information in the narrative, as credit card numbers, change your Yahoo password would have sufficed.

  • Text backup question / deleted

    I accidentally deleted one of my iPhone SMS 6 Plus.  They always show on my iMac and iPad but I fear when an AutoSave occurs, it will back up the iPhone and remove them to two other devices. What will happen?  I use iCloud if that makes a difference.

    Hi melissahh625,

    I understand that you have questions about your messages deleted on different devices. I know that it is important to have a handle on your data, so I'm happy to help you.

    When you receive messages, they are stored on different devices. This means that when you delete a device they will not be deleted on the other. This is the case, even if one of your backup devices to iCloud that these backups are specific to devices, as well.

    Thank you for using communities Support from Apple. See you soon!

  • Question

    Look I went to a new site called collabmix.com, and in any case I tried one of my samples Logic Pro download for someone else to try to collaborate with and help me through my song production. In any case when I go to download, the site accepts only gif, jpg, jpeg, or png. How to record my song pro logic and make a jpeg or jpg file? Please someone... IM new to this site and maybe someone asked this already so I'm sorry if this is a redundant question. Anyway ill be looking for a response from the community here. Thank you

    GIF, jpg, jpeg, or png are all formats of image, audio files or formats of logic.

    I got a peek on the site but I'm not register. I'm going to guess and say you are in the wrong place to download your song.

Maybe you are looking for