How do to keep control for location

In the app I develop, I need constantly to find the location according to a time interval set by the user and then calculate a distance from this place.

I tried to put in a simple while loop, I even tried the Sleep() function but when I test it on the Simulator, it does not work so I think I'm doing something wrong.

Here's some of my code where I have the question, I need the part that verifies my place to be constantly running and have the function that calculates the distance be run with him rather than the user clicks on the button. I'm having a very difficult time to do this... I would really appreciate the help. Thank you.

final class WhenImCloseScreen extends MainScreen
{
     double userLat, userLon, curLat, curLon;
     EditField lonuser, latuser, distuser;
     BasicEditField lat, lon, dist;
     RichTextField result;

    public WhenImCloseScreen()
    {
        super();
        //I added other on screen elements here

        ButtonField btnOK = new ButtonField("Calculate Distance", ButtonField.CONSUME_CLICK);
        btnOK.setChangeListener(listener);
        add(btnOK);

        Location loc = getCurrentLocation();
        if (loc != null)
        {
            curLat = loc.getQualifiedCoordinates().getLatitude();
            curLon = loc.getQualifiedCoordinates().getLongitude();
            lat.setText(String.valueOf(curLat));
            lon.setText(String.valueOf(curLon));
        }
    }

     FieldChangeListener listener = new FieldChangeListener()
     {
         public void fieldChanged(Field field, int context)
         {
            if (latuser.getText().equals(null) || lonuser.getText().equals(null) || latuser.getText().equals("") || lonuser.getText().equals(""))
            {
                 result.setText("Coordinates have not been found yet!");
            }
            else
            {
                userLat = Double.parseDouble(latuser.getText());
                userLon = Double.parseDouble(lonuser.getText());
                lat.setText(String.valueOf(curLat));
                lon.setText(String.valueOf(curLon));
                int Intdist = DistanceBetweenCoords(userLat, userLon, curLat, curLon);
                dist.setText(Intdist + " meters");

                if (distuser.getText().equals(null) || distuser.getText().equals(""))
                {
                    result.setText("");
                }

                if (Intdist < Double.parseDouble(distuser.getText()))
                {
                    result.setText("You are within the radius point!");
                }
                else
                    result.setText("");
            }
         }
     };
}

You must follow these steps to configure the system:

  1. Get a reference to a LocationProvider using LocationProvider.getInstance (). You must pass a Criteria object that specifies what type of notifications of the location that you want to receive.
  2. Set up a LocationListener will perform some processing you want to occur whenever the LocationProvider issues a notification.
  3. Tell the LocationProvider your LocationListener by calling setLocationListener().

When you no longer want to receive notifications, call setLocationListener (null).

From your description, you can use a ProximityListener instead of a LocationListener. The steps are almost identical to the above.

Tags: BlackBerry Developers

Similar Questions

  • How to set parental controls for the zone

    Im trying to set up parental controls for children. I have set up for the clock, but they got smart and started to change the time zone. Does anyone know how to set up parental controls for the time zone... At least the name of the program for the time zone. Any help is appreciated, thanks.

    Im trying to set up parental controls for children. I have set up for the clock, but they got smart and started to change the time zone. Does anyone know how to set up parental controls for the time zone... At least the name of the program for the time zone. Any help is appreciated, thanks.

    If you have a superior taste of Windows 7 you can / must define the rights to change the time system and time zone via the policy editor gpedit.msc. They are defined in the strategy/Security Settings user rights assignments / Local. Ensure that only administrators and the Local Service can change these settings.

    If you have a taste less then you need to do it via a number of commands in the console, i.e.
    net localgroup
    NTRights users - r seSystemtimePrivilege-u
    NTRights u users - r seTimezonePrivilege

    You can download ntrights.exe here: http://www.microsoft.com/download/en/details.aspx?id=17657. If you choose this option, you may need to then more detailed instructions. Post again if this is the case.

    Note also that your children are more intelligent, they will find additional methods to bypass your restrictions. If you let me sit in front of your machine then I would be able to do as I please in less than five minutes, without knowing a single password. This means that you may need to solve this problem by teaching ways rather than technical.

  • IPhone hacked, how to deepen the control of location services?

    So my router, mac and iphone got hacked, more than likely by the FBI.  They were investigating a person in my building, but it has proved to be a dead end.  Apparently, they decided to illegally monitor me.  My location service is initially resembled the image as an attachment, with the error message of the filling.  Now, I can't even access the tab "Location services" because it is faded and I can't draw in this.  I would like to get information from my phone to apple because I am sure that my phone has been violated by an iMessage randomly that I received.  Any ideas on how I can have apple examine how he missed their OS 9.3 on my phone?  The other problem is that I'm in Puerto Rico, where there is no apple on the island store and I won't be back on the Mainland for some time.

    I also sent the screenshot of iMessage in question to the [email protected] but did not receive an automatic reply, so I don't know if apple never received.  In any case, to check if it has been received?

    Unless you have jailbroken your iPhone, it could not have been hacked away. There is no way to "violate" an iPhone via a random iMessage. If iMessage takes you to a link that asks you if you want to install a profile and press 'Ok', there are a limited number of things that anyone could join. To check this, go to settings > general > device management and delete everything that you are not familiar with.

    You can also return to this thread:

    Location services

  • Oracle of the MAF: Activate the Navigation controls for goLink

    Hello!

    I have installation media icons to make it easy for our community of users to 'love' or 'share' content, connect, tweet, etc...

    When the user clicks on the icon URL is launched in the display pages Web of the MAF.  UNFORTUNATELY the navigation controls are grayed out.  For this reason my users aren't able to return easily to the mobile application.   How to enable navigation controls for a URL that is launched in a goLink?

    Of course: I have the URL in my white list (under MAF - application.Xml-> Security).

    Please let know us at your earliest.  Thank you!

    TreeStrepek

    The solution to this is to
    ..............................

    1. Yes - set whitelist URL as shown above.
    2. Create each destination site in as long as separate function type = "Remote URL"
      1. This launches the Web site inside of a display of web pages (navigation, web inter view control, then another social media link resets source feature can be selected)
    3. Set the AMX page with components commandLink (icon only, no text)
    4. For each commandLink (that is to say-twitter icon or fb icon, etc...)
      1. Action = #{newsBean.goTwitter}
    5. The newsBean class will have a method "goTwitter".  Inside there is 1 line of code.
      1. gotoFeature ("URL remote FeatureID").

    It's beautiful.  It works as expected.

  • I have a new computer with operating system Windows 10. Sometimes items automatically starts searching for photos of my external hard drive to download. I don't want these pictures to include. How can I keep items the search from my computer

    I have a new computer with operating system Windows 10. How can I keep the elements search my computer for the pictures to download in elements? I want to control what is added to the elements.

    Harold8838 wrote:

    I have a new computer with operating system Windows 10. How can I keep the elements search my computer for the pictures to download in elements? I want to control what is added to the elements.

    It is in the file menu of the Organizer (watched folders).
    Don't include no matter what path if you do not want the Organizer to look for new files.

  • How can I keep my 2 email accounts and all others using HTML? It lasts only temporarily, i.e. for the day...

    (1) - when I open Firefox, I recently have clicked on the hyperlink at the bottom of page html, it works very well for my gmail and yahoo accounts. However, it is not a permanent solution, it apparently lasts only for the daily session. How can I keep my internet, al. HTML permanently?

    (2) - Firefox v24.0 is supposed to be fast and quick! However, I am not find it so. When I click on a link or open a tab, it is frustrating that the tab work too long to open... More than not, I click reload, which appears to help a little. Any suggestions?

    (3) - I just printed the Mozilla Support Q & A on the Firefox error message indicating that it cannot load the site... How to I remedy this, as it appears constantly with my Yahoo email login?

    (4) Finally, a few weeks ago I jumped inadvertently bookmark 'HEALTH' (I have a bookmarks toolbar), which is excellent (had with WinXP too, now with Win7), but it seems to me to pop, double click or something or other, which blew a folder of bookmarks in the wild blue yonder! I have posted responses here and elsewhere, print and read all instructions variable to navigate and search, all nothing is helping. More sage advice please?

    with satisfaction, and thanks in advance.

    # 1, is the link to use HTML to simplify the interface?

    Maybe it's that the site stores your preferences in a cookie, and you may have set Firefox to delete the cookie when you quit the browser. There are a few built-in ways to do this:

    • The Firefox value "keep [cookies] until: I close Firefox" on the Privacy Options (you can create an exception for your messaging sites)
    • The value 'Clear history closing Firefox' Firefox on Privacy Options
    • A private browsing window allows to visit the site of your mail

    It is also possible that the modules or external software can clean the cookies, or that there is a problem with the database file Firefox uses cookies to store.

    # 2, you have this problem just started recently? If you find one any relationship with the site content type (for example, pages that use Flash or other media)?

  • How to recharge the remote control for Apple TV 4

    How to recharge the remote control for Apple TV 4

    Recharge your Siri or Apple TV Remote - Support Apple Remote

  • Re: How to reconfigure the remote control for Qosmio F50?

    Hello
    I have a Qosmio F50, which came with a standard remote control for applications like media library etc, how do I reconfigure the keys to do exactly what I want it to do?

    For example the button power on the remote control to completely stop the machine instead of standby

    Thank you
    Dan

    Hello Dan

    Why do you think something like this is possible? What is this described in s operating manuals.
    If something like this can be done, it must be described in the manuals?

    In 10 years Toshiba has offered several different notebooks with the remote, but something like this was never possible and remote control buttons were always with defined function.
    You have some really cool ideas.

  • How can I control the location where appears a button "dialogue"?

    I have multiple loops simultaneously and in each of them, I "buttons of the dialog box." In some cases, "buttons in the dialog box" appear too lapping. Is there anyway that I can control the location where a "dialog box" button on the monitor?

    Thank you

    Chuck M.

    You create your own Subvi that behaves like a dialog box.  In this way, you can control the appearance and location.  Look through the viewfinder of the example for dialog demo start.

  • Parental control: How can I set up parental controls for your computer, as well as with the internet

    How can I do to set up parental controls for your computer, as well as the internet. Can you please provide me with detailed instructions? Thank you

    Click on the start ORB, then select "Help and Support" and type "parental control" in the help search box.

    "xxHoneyBeexx" wrote in the new message: * e-mail address is removed from the privacy... *

    How can I do to set up parental controls for your computer, as well as the internet. Can you please provide me with detailed instructions? Thank you

  • How to control the location of an XP Mode application window when it is maximized?

    How can I control the location of an XP Mode application window when the window is maximized?

    I'm running an application in XP Mode on a Win7 workstation company with three monitors.  The primary monitor is on the left.

    I opened the application in XP Mode and it will display on the primary monitor.  When I maximize the application window, the window moves to another monitor and displays only the part of the window.

    As an experiment, I have rearrainged the three monitors so that the screen on the right was the primary monitor.

    Now when I run the application in XP Mode, it opens on the primary monitor on the right correctly, and when I maximize, it remains on this monitor rigthmost.

    So, how can I control the location of the application window XP Mode so that it remains on this primary left more monitor when it is maximized.

    Thank you.

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums.

    TechNet Forum

    http://social.technet.Microsoft.com/forums/en-us/w7itprovirt/threads

    Hope this information helps.

  • I have a pdf form that has 4 columns, with each column having 28 check boxes and text between. I did so he goes by column, but when I do anything for a checkbox it takes it out of line. How can I keep that from happening?

    I have a pdf form that has 4 columns, with each column having 28 check boxes and text between. I did so he goes by column, but when I do anything for a checkbox it takes it out of line. How can I keep that from happening?

    You talk about the tab order? If Yes, go to Edit - Preferences - forms and make sure the box "Automatically adjust tab order when changing fields" is NOT checked.

  • How to download the program Volume control for the taskbar

    Where can I get the installer of the volume control for my taskbar. I've triedControl Panel >sounds and Audio devices > check "Place Volume in the taskbar icon .

    When I check the box for "place volume icon in the taskbar" it gives me an error and says "Windows cannot display the control volume on the taskbar because the Volume control program has not been installed. To install it, use Add/Remove programs in Control Panel.

    Where can I get the program from?

    You mention that your netbook is HP. Most of the HP products have a recovery partition. If this is the case:

    -Click Start-> Run

    -Type in cmd

    -Type in the following, substitute the C:\ and D:\ readers with your partition recovery and partition system respectively:

    Expand c:\i386\sndvol32.ex_ d:\windows\system32\dllcache\sndvol32.exe

    -Press enter, and then type:

    Expand c:\i386\sndvol32.ex_ d:\windows\system32\sndvol32.exe

    -Type exit and press ENTER.

    Your Volume control should now be restored. You can check this by opening the sound and Audio Control Panel devices and by checking the box to the volume icon to Place in the taskbar.

    If your problem is not solved or there is no such thing as a recovery partition after the return

    Hope this helps

    ____________________

    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Once I have to zoom on video in post production using the effects Panel and movement controls &gt; scale how can I keep the sharpness of the image?

    How can I keep the sharpness after I Zoom.

    Never exceed 100% scale.  The image is going to deteriorate.

  • How can I get more controls for audio?

    Problem: Audio only has the game and the pause button (I wonder why)

    I also need before young and rewind options

    The video has this feature

    I tried to create a video with only the sound but its size is too large (16:9) and seems impossible to crop, I need a bunch of 505 x 33 px

    Mask the video isn't an option for me, the controls of the cultures and is not very flexible way to handle the large number of audio that I have manage each issue of my magazine

    Any suggestions?

    Thanks in advance

    Italy Claudio

    Hello Claudio,.

    one option is to use HTML 5 and find a script that offers more controls for the media.

    I stumbled on the next page, the player has quick checks front and back. You can try to change the source to your liking files, and I think it's pretty cool:

    http://tympanus.NET/Codrops/2012/07/12/old-school-cassette-player-with-HTML5-audio/

    Ercole

Maybe you are looking for

  • How can I install additional memory in iMac end 2012?

    Is there something special I should know about installing more memory in my end 2012 27 "iMac?  I installed before memory in older iMacs. Thank you

  • Satellite A30 - card WLAN Compatible

    Hello.Would be the Wireless LAN Mini PCI Card - 802.11a/b/g (number PA3298U-1MPC) to be compatible with the satellite a30. In the compatibility list it mentions only the pros of the satellite, the a30 is compatible with other mini-pci cards, so I don

  • G62 Touchpad lock stuck

    When I use the touchpad on the laptop lock feature (the little orange button at the top left of the touchpad) I can't unlock. It's something that only started happening recently, not that I use it all that often, but I know at the end of may, it work

  • Reverse the mouse buttons on a laptop running Vista Ultimate

    I use Vista Ultimate on a laptop. I want to reverse the mouse buttons.  When I check the control panel to reverse the buttons on the touch pad works like a 'right click '.  How can I reverse the buttons without messing up the keys.

  • BIOS takes more time to load... Did help fix me!

    Today my friend asked me to check his graphics card, if I traded mine to check it out. And after I put my graphics card I started facing the issue of screen BIOS long. Plug it into the USB cables resolved. And I reduced to UPS APC connection cable. A