How can I get my current coordinates (latitude and longitude)?

Hello world

I'm trying to design an application, but I don't know if I want to do is possible.

I want to choose the current place of residence and then display in a map.

Something like:

MapView mapview = new MapView();

Ask my current location lat and LNG somehow and save them in the lat, long variables.

mapview.setLatitude (lat);

mapview.setLongitude (lng);

mapview.setZoom (4);

Invoke.invokeApplication (Invoke.APP_TYPE_MAPS, new MapsArguments (mapview));

(I mean, I want to show a different mapView depending on where I am)

My problem: can be found my current latitude and longitude? How can I do?

I'm completely lost on how to start looking for information, then I'll be happy to receive any help.

Kind regards

I changed my code and when I try it in the Simulator (my device Simulator is a 9930), it works.

Now I try this code on my own devide a 9300 and I get whenever a message saying "invalid location.

Can someone help me fix my mistake?

This is the code I use:

public class extendsscreen Mapa

{

public Mapa()

{

Criteria myCriteria =newCriteria();

myCriteria.setHorizontalAccuracy (Criteria.NO_REQUIREMENT);

myCriteria.setVerticalAccuracy (Criteria.NO_REQUIREMENT);

myCriteria.setCostAllowed (false);

myCriteria.setPreferredPowerConsumption (Criteria.NO_REQUIREMENT);

myCriteria.setPreferredResponseTime (100);

Try

{

LocationProvider provider = LocationProvider.getInstance (myCriteria);

provider.setLocationListener (newhandleGPSListener(), 10, -1, -1);

}

catch (LocationException Lex)

{

return;

}

}

public public static class handleGPSListener implementsLocationListener

{

public void locationUpdated (LocationProvider provider, a place)

{

Coordinates of c =null;

final double lat;

final lon double ;

if (location.isValid ())

{

c = location.getQualifiedCoordinates ();

LAT = c.getLatitude ();

LON = c.getLongitude ();

UiApplication.getUiApplication () .invokeLater (newRunnable()

{

public void run()

{

Dialog.Alert (lat + "-" + lon);

}

});

MapView mapview= new MapView();

mapview.setLatitude ((int)lat);

mapview.setLongitude ((int)lon);

mapview.setZoom (4);

Invoke.invokeApplication (Invoke.APP_TYPE_MAPS, new MapsArguments (mapview));

}

on the other

{

invalid location

UiApplication.getUiApplication () .invokeLater (newRunnable()

{

public void run()

{

Dialog.Alert ("invalid location");

}

});

}

}

public void providerStateChanged (LocationProvider provider, intnewState)

{

if (newState is LocationProvider.OUT_OF_SERVICE)

{

Unavailable because of governed by a COMPUTER GPS policy

UiApplication.getUiApplication () .invokeLater (newRunnable()

{

public voidrun()

{

Dialog.Alert ("GPS out of stock because of the governed by a COMPUTER policy");

}

});

}

else if (newState is LocationProvider.TEMPORARILY_UNAVAILABLE)

{

no GPS fix

UiApplication.getUiApplication () .invokeLater (newRunnable()

{

public voidrun()

{

Dialog.Alert ("no GPS solution");

}

});

}

}

}

}

Tags: BlackBerry Developers

Similar Questions

  • I reinstalled Firefox Desktop, I downloaded my favorites of Carbonite, how can I get the current Firefox to accept?

    See above

    I reinstalled Firefox Desktop, I downloaded my favorites of Carbonite, how can I get the current Firefox to accept?

    You do backup your bookmark as a .json file?

    Restoration of bookmark

  • How can I get my laptop Dell Latitude D830 to read my HHB Professional Minidisc recorder CDM 500?

    Original title: my computer does not read my minidisc recorder

    How can I get my laptop Dell Latitude D830 running Microsoft Windows XP to read my HHB Professional Minidisc recorder CDM 500?

    Hi EnverBrowne,

    Thanks for posting in the Microsoft Community.

    I'm sorry to know that you are facing a problem to use HHB Professional Minidisc recorder CDM 500.

    It would be useful that you can answer these questions to help you further.

    1. what exactly happens when you try to use the recorder? You receive messages or error codes?

    2. using the recorder for the first time?

    3. have you made a recent software or hardware changes to the system?

    You can try to start the computer and peripheral equipment Fixit from link and check if it helps:

    Hardware devices do not work or are not detected in Windows

    If you need further assistance, please answer and we will be happy to help you.

  • After downloading an application I see is no longer the splash screen, how can I get rid of the app and restore my pc when I do not see the screen

    After downloading an application I see is no longer the splash screen, how can I get rid of the app and restore my pc when I don't see the screen, please help

    Hello

    Do a system restore to a date before you had this problem:

    "How to make a restore of the system in Windows 8 and 8.1" . "

    http://www.eightforums.com/tutorials/4692-System-Restore-how-do-Windows-8-a.html

    Follow this path to a Safe Mode system restore:

    "5 ways to boot mode safe Windows 8 & Windows 8.1"

    http://www.7tutorials.com/5-ways-boot-safe-mode-Windows-8-Windows-81

    See you soon.

  • How can I get him to minimize, maximize, and close buttons appear in Adobe Reader XI

    How can I get him to minimize, maximize, and close buttons appear in Adobe Reader XI

    davidm96675864 wrote:

    I use Kaspersky Internet Security, which is updated (Version 15.0.0.463 (b)).  Thank you, David.

    The latest version is 15.0.2.361.

    Kaspersky Internet Security 2015 | Latest releases | Kaspersky Lab

  • How can I get my list of sites and FTP access, password etc... (old win 7 on an external drive)

    Hello, this is not considered a regular registered sites export (I have many)... and it's a mistake.

    In short, after computer out, I got the hard drive I have USB (old win 7 pro on an external drive)

    How can I get my list of sites and FTP access, password etc...

    they are encrypted in the registry if I'm not mistaken?

    any idea?

    Thank you.

    (Google translation)

    proceedings found:

    Just do an export of the new common/site .reg file and the modifier with the values of the old and then importing, everything works

    Thank you

  • How can I get the current path of LUN?

    I want to know the active path for all my lun. How can I get this value?

    Tios thanks!

    Best regards

    Xavier

    VCP4 and professional VCP3 certified VMware.

    -


    If upon that esta o any other campaign respuesta ha sido utility, votalas. Gracias.

    If you find this or any other information useful or appropriate, please consider giving points. Thank you.

    You could do something like that

    $report = @()
    Get-VMHost  | %{
         $esx = $_
         $_ | Get-ScsiLun | %{
              $lun = $_
              $_ | Get-ScsiLunPath | %{
                   $row = "" | Select HostName, LUNname, Path, Active
                   $row.HostName = $esx.Name
                   $row.LUNname = $lun.CanonicalName
                   $row.Path = $_.Name
                   $row.Active = $_.State
                   $report += $row
              }
         }
    }
    $report
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • How can I get rid of vista completely and install xp?

    How can I get rid of vista without having to run 2 operating systems?  and install xp?

    Check the computer manufacturer's Web site if there are all the XP drivers for your model computer.
    If there is none, forget XP.

    Next thing you'll need is to buy a XP disc.

    Then perform a new installation of XP, Vista removal in the process.

    See you soon.

  • How can I get rid of Acrobat DC and go back to my old Acrobat Reader?

    I don't like the way Acrobat DC invaded my computer. I was perfectly satisfied with the previous version. How can I get that back?

    Hi errolb51388624,

    You can run this tool cleaner Download Adobe Reader and Acrobat cleaning - Adobe Labs tool to uninstall the DC version, retsrat your system & reinstall 11 Reader using this link Adobe - Adobe Acrobat Reader DC Distribution.

    Kind regards

    Nicos

  • How can I get the current paragraph?

    I want to get the current paragraph where the insertion point is.

    How can I do this in FDK?

    Ch,

    I can answer some of these questions, but if you have decided that this thread is replied, please give credit to Mike.

    About the audit for a FO_Pgf object, you shouldn't have that. I think that there is some obscure cases where F_ApiGetTextRange() gives you an object that is not a paragraph... I forgot exactly but I think it has to with a text graphic subject line or something like that. I could be wrong. In any case, if you have a stream of regular text with an insertion point, you will get a paragraph object.

    This line will abort the operation if any text is selected. Do you really want that?

    If (insertionPoint.beg.objId! = insertionPoint.end.objId)

    This line will abort the operation if several paragraphs are selected. Do you really want that? Without this verification, you will always get the text of the first selected paragraph.

    If (insertionPoint.beg.offset! = insertionPoint.end.offset)

    Otherwise, the code looks OK to me, at least regarding the FDK calls. You have problems with him?

    Russ

  • How can I get the current date?

    Hello!

    I two EditFields that will act as a filter, so a user can say display me records from here to there.

    I would like to default dates today at 7 days before.

    Here is the code that I currently have:

    Border border = BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1));
    txtStartDate = new EditField("", "");
    txtStartDate.setBorder(border);
    Background txtBackground = BackgroundFactory.createSolidBackground(0xFFFFFF);
    txtStartDate.setBackground(txtBackground);
    add(txtStartDate);
    
    Border borderB = BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1));
    txtEndDate = new EditField("", "");
    txtEndDate.setBorder(borderB);
    Background txtBackgroundB = BackgroundFactory.createSolidBackground(0xFFFFFF);
    txtEndDate.setBackground(txtBackgroundB);
    add(txtEndDate);
    

    Is there something like a DateTime.Now to Blackberry? How can I achieve this? Thanks a lot for the help guys.

    Ok........

    Use this...

    Date date;
    String currentdate = new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()));
    
    ------------------------------------------------------------------------------------Press Kudo to say thank to developer. Also Press the Accept as solution Button when u got the Solution.
    
  • How can I get the current state "onto the Pixels?

    Hello community,

    Here's the function that creates a switch that handles "snap to Pixels":

    index.html:

    <div id="STP_input" onclick="switchOnOff(this)">
         ...
    </div>
    

    main.js:

    $("#STP_input").click(function () {
         var a = switchOnOff(this);
         if (a) {
              csInterface.evalScript('switchSTP(true)');
         } else {
              csInterface.evalScript('switchSTP(false)');
         }
    });
    

    HostScript.jsx:

    function switchSTP(checkBTN) {
        'use strict';
        
        var condition;
        if (checkBTN === true) {
            condition = true;
        } else {
            condition = false;
        }
    
        var idsetd = charIDToTypeID( "setd" );
        var desc26 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref6 = new ActionReference();
            var idPrpr = charIDToTypeID( "Prpr" );
            var idtoolsPreferences = stringIDToTypeID( "toolsPreferences" );
            ref6.putProperty( idPrpr, idtoolsPreferences );
            var idcapp = charIDToTypeID( "capp" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref6.putEnumerated( idcapp, idOrdn, idTrgt );
        desc26.putReference( idnull, ref6 );
        var idT = charIDToTypeID( "T   " );
            var desc27 = new ActionDescriptor();
            var idtransformsSnapToPixels = stringIDToTypeID( "transformsSnapToPixels" );
            desc27.putBoolean( idtransformsSnapToPixels, condition );
        var idtoolsPreferences = stringIDToTypeID( "toolsPreferences" );
        desc26.putObject( idT, idtoolsPreferences, desc27 );
        executeAction( idsetd, desc26, DialogModes.NO );
    
        return;
    }
    

    But when I hide the Panel and show once again, that the switch back to the default state, turn on my Panel, not "hook to Pixels" PS settings setting. Is it possible to get the current status 'Hang the pixels' setting? How?

    Best regards.

    See post 8 in this thread:

    Re: Need someone to update or create script: "snap to grid of pixels.

  • How can I get rid of the DC and back to 11?

    I need to open PDF files in a secure environment, I do not store them on my computer and want not stored in a cloud or anywhere else.  How can I go back to 11?

    Hello

    CD documents are stored in a location that is secure only.

    Here the cloud does not mean that your files are accessible to all.

    Your documents are safe and the cloud here means ease of access, as you can access your documents from seen so other devices simply by logging into your account.

    You would also save the file to cloud document if you want to access from different devices.

    You could save on anywhere on your computer.

    The mobile link should be lit to keep this functional feature or else it would behave in the same way.

    You wouldn't be able to view documents recently consulted by other devices. Documents of SUVs would change for each device if mobile link is off.

    Where you need to go back to the previous version of the player, you may consult the following link.

    https://get.Adobe.com/reader/Enterprise/

    However, you must uninstall the current version of the player running on your system.

    Concerning

    Sukrit diallo

  • How can I get rid of many ads and coming dating site in my email

    How can too many ads I get rid of this junk

    Even if your profile says you're on 10.8 concepts are the same

    Address postal (Yosemite): reduce the spam in your Inbox

    any with your email in their address book on a public messaging system like yahoo and google, etc. can inadvertently also contribute to your number of spam. If you sign up for sites with your e-mail address or if someone is using your email address then expect entities behind these sites to continually bombard you with junk because it costs them nothing to do, and they can make money by selling your account info.

  • How can I get rid of video messages and return to video calls on an iPAD?

    Somehow, I managed to transform video calling to video messages, I have everything together to get rid of the messages and return calls. How do I do that?

    The video call option also lacks for contacts who are online? Video messaging option normally appears to contacts who are offline, you can also send video messages, while the contact is offline.

Maybe you are looking for