How to get the current location in the event thread?

Hello!

Can U pls tell me how to get the location where the thread object, it is in method() execution of MenuItem. PLS, tell me-

I also used the different thread for the getLocation() method. But I do not have the coords of geo location...

PLS, suggest me-

My code is as below:

    private MenuItem getGeoCodes=new MenuItem("Current Coords",100,1){

                             public void run(){
                                 double[] coords=getLocationCoords();
                                 this.wait(12000);
                                 System.out.println("Latitude :"+coords[0]+" "+"Longitude:"+coords[1]);
                             }

                 };

    private double[] getLocationCoords(){
        Criteria criteria = new Criteria();
        criteria.setHorizontalAccuracy(500);
        criteria.setVerticalAccuracy(500);
        LocationProvider locationProvider = LocationProvider.getInstance(criteria);
        Location location=null;
        new Thread(){
           public void run(){
                   locationProvider.getLocation(60);
           }
        }
        QualifiedCoordinates qualifiedCoordinates=location.getQualifiedCoordinates();
        double[] coords=new double[]{qualifiedCoordinates.getLatitude(),qualifiedCoordinates.getLongitude()}   ;
         return coords;
    }

But I myself NullPointerException. Coordinates get successfully, if we run the location capability in different function, rather than the event thread.

Please help me-

In my opinion, which may be too complicate things a bit. I think he's trying to do is register a LocationListener with his object of LocationProvider. Callback methods, send a message to the UI event thread as follows (no need to spawn threads):

UiApplication.getUiApplication().invokeLater( new Runnable() {
    public void run()
    {
        // This code will execute on the event thread
    }
});

EDIT: If your interval is short, you can consider implementing this executable as a class and store an instance in the front.

Tags: BlackBerry Developers

Similar Questions

  • How to get the event when we change our simcard in BB device

    Hi all

    Please, someone tell how to get the event or any listener method that can automatically called when we change our SIM card device.

    Thanks in advance,

    TEJ

    Hi Tej,

    I came across some post, which may be useful for you

    http://supportforums.BlackBerry.com/T5/Java-development/is-there-a-way-to-get-the-mobile-or-phone-nu...

    http://supportforums.BlackBerry.com/T5/Java-development/is-SIM-ID-really-exist/m-p/54407#M5954

  • How to get the event when you click Add another button in a table.

    Hello
    How to recognize the event in processFormRequest click on the button Add another line of the footer of a table?

    Suppose if the ID is anotherRow (I mean ID of the button to add another line of the footer)

    If I give if (pageContext.getParameter ("anotherRow")! = null)... its not recognizing the event that is returning null only...

    I want to perform certain actions when the user clicks Add another line of footer. Please let me know the details of how identify when add another line is clicked...

    Thank you
    Srikanth

    Hello

    If you have only one table with add_row_button, and then copy the following code works perfectly

    If (tableBean.getName () .equals (pageContext.getParameter (SOURCE_PARAM)))
    (& ADD_ROWS_EVENT.equals (pageContext.getParameter (EVENT_PARAM)))
    {
    ...
    }

    tableBean is the Handle for your advanced table, hope, it will help you.

    Kind regards
    Out Sharma

  • How to get the event target?

    I recorded the event mask depending on:

    App.notifiers.Add ("Hd",.. mpfprojectdir\dev10\src\csharp\projectbase.file path);

    Now, how can he obtain the object that triggered the event?  [app.active document.activeLayer] give me only the layer ".  Of course, this does not work in a scenario where the user hides a layer that is not selected.

    I'd appreciate any help!

    Action handler has no direct access to objects in the object model. It has its own class and object. Sometimes, there may be a more direct access by name. If the event descriptor was the index of the layer or the ID you can use instead of the name.

    Sorry, when I threw together for you I only tested hidding layers that do not have the activeLayer. I don't think that the alert is empty is because the top layer was hidden. I think it's because the activeLayer was hidden so the actionReference is different.

    Try this (which seems to work for me with both)

    try {
        if (arguments.length >= 2) {
        var desc = arguments[0];
        var event = arguments[1];
        // make sure it's the hide event
        if (event == charIDToTypeID('Hd  ')) {
            // get the list of what was hidden
            var list = desc.getList(charIDToTypeID('null'));
            // get the actionReferences from the list
            var ref = list.getReference(0);
            var psClass = ref.getDesiredClass();
            // make sure it was a layer that was hidded
            if(psClass == charIDToTypeID('Lyr ')){
                // check to see what is in the reference
                var dataEnum = ref.getForm();
                // should either be an enum if activeLayer
                if(dataEnum == ReferenceFormType.ENUMERATED) {
                        alert(app.activeDocument.activeLayer.name);
                }else{// or the layer name
                    alert(ref.getName());
                }
            }
        }
      }
    } catch (e) {
      alert( "Error: " + e + ":" + e.line );
    }
    
  • How to get the worker thread to wait for a course of UI thread ends

    I managed so far to have a thread so far work send a signal to a class in the UI thread, view a map, capture the data in this worksheet and send a signal to slot in worker thread.

    To test that the steps in the UI could do I just put the worker thread in a loop with a sleep and a counter.

    What I don't know is how interrupt the loop when the final signal is sent. I know that the signal is received but the crack does not control until that the loop ends while I want the slot for the control reception and tell the loop at the end.

    I read the documentation in BlackBBerry and Qt on the threads, mutexes, condvars, QWaitCondition etc., but none of them quite make sense to me in this situation and I can't determine which would be the best or the only one to use here.

    Anyone could do his script to work for them?

    Does not appear that the use of mutexes, condvars, are applicable to this situation, as I have only main and a worker thread to synchronize. Signal wire loop blocks so slot does not control until the loop ends. This makes sense because a thread can have only a single process point of execution. Maybe with another thread, it might work but cannot solve the logic.

    However, to find a simple solution using a thread with a loop containing beds and overall, set variables to date by the UI thread that the loop check and then fall back to sleep or ends. I don't allow so many people then, if the loop has not yet finished I invited user "More time to enter the data do you need?" and set end or loop.

  • How to get the events of the ItemRenderer

    Hello, I have a little problem. In my application, I use a list and build its elements with an itemRenderer. In this itemRenderer I have on each line, 1 label and 1 button. When I press the button I want to send this event in my main application... How can I create a communication between myApplication and itemRenderer?

    Thx for all

    Max

    
    
        
            
        
        
            
                
                    
    
                        
                            
                        
    
                    
                
            
        
    
    

    You can use the code above. Let me know if you have any questions.

  • How to get the event when the window is iconified?

    I want to set animation after I click the icon.
    Please help me.
    Thank you.

    stage.iconifiedProperty () .addListener (new InvalidationListener() {}
    @Override
    public void invalid (observable observable) {}

    }
    });

  • How to get the page change event?

    Hello.

    I know that get changed event document as ISignalMgr-> GetServiceID of CResponder::Respond.

    But how to get the event page?  average of the event's page add, delete, etc...

    Thank you.

    Hi K159,.

    You can spy on the InDesign debug Test/Spy/SpyPreferences menu for the observer notifications. Can add or remove a page and to analyze the output of the spy.

    On the kDocBoss, there is an interface IPageList form you can get the number of pages.

    Markus

  • How to get the current timestamp in C++ to the BB10 project

    Please help me how to get the current timestamp in C++. Thanks for your help!

    Following your suggestion,

    QTime is only for a day.  http://developer.BlackBerry.com/Cascades/reference/QTime.html#details

    I found "QDateTime" of references of the API: http://developer.blackberry.com/cascades/reference/qdatetime.html#toTime_t

    QDateTime = now QDateTime::currentDateTime();
    timestamp long = now.toTime_t ();

    But I got an error. I searched but no results are clear:

    -variable 'QDateTime now' initializer has but
    incomplete type
    -type incomplete "QDateTime" used in the nested name
    specifier of

    I am a newbie. So thank you for your help

  • How to get the current wording of the BlackBerry device with the BlackBerry App?

    Hello!

    I'm new to BlackBerry,

    Can u tell me pls, how to get the current language of the device using the program...

    PLS, suggest me...

    Locale.getDefaultForSystem () will give you the regional settings currently selected.

  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

  • How to get the frame number current timeline using jsx?

    How to get the frame number current timeline using jsx?

    Thanks for the link!

    Clarification: I was looking for the current image on the timeline of the video. OP he mentions that he had found how to get that so I searched a bit more and found this thread: Re: can I inpoint in read/write and out-point of the clips in a group of video with scripts? They have the following functions, I have not tried yet, but it seems like it should work.

    function getCurrentFrame() {}

    try {}

    Var ref = new ActionReference();

    ref.putProperty (charIDToTypeID ('Rprp'), stringIDToTypeID ('currentFrame'));

    ref.putClass (stringIDToTypeID ('timeline'));

    var / / desc = new ActionDescriptor();

    desc.putReference (charIDToTypeID ('null'), ref);

    var TC = executeAction (charIDToTypeID ('getd'), desc, DialogModes.NO);

    Return TC.getInteger (stringIDToTypeID ('currentFrame'));

    } catch (e) {return null ;}

    };

  • How to get the 'DAY' based on the territory of current account held a number between

    Hi all

    Looks like I'm at the end of my intelligence here but how to get the 'DAY' based on the territory of current account with a number between 1 and 7? Oracle has functions to extract the day of the week, but I can't find the other way around.
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    
    SQL> alter session set nls_territory=AMERICA;
    
    Session altered.
    
    SQL> select to_char (sysdate, 'D') from dual;
    
    T
    -
    3
    
    SQL> alter session set nls_territory=GERMANY;
    
    Session altered.
    
    SQL> select to_char (sysdate, 'D') from dual;
    
    T
    -
    2
    I need a way to know that the number '3' on the database with NLS_TERRITORY = AMERICA means a 'Tuesday' or the number '2' on a database with NLS_TERRITORY = GERMANY means "Tuesday" as well.

    Hope I am clear enough.

    And wish you all a happy new year :)

    Kind regards
    Smail

    Use the format "IW" to get the date of Monday and the format "DAY" to get the "first day of the week. Then compare dates to see if they are identical.

    ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
    
    SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday",
    TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week",
    MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON"
    FROM DUAL CONNECT BY LEVEL <= 7;
    
    Monday    NLS First day of week 1 if day 1 = SUN, 0 if MON
    --------- --------------------- --------------------------
    31-DEC-12 30-DEC-12                                      1
    24-DEC-12 30-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    
    alter session set nls_territory = 'FRANCE';
    
    SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday",
    TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week",
    MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON"
    FROM DUAL CONNECT BY LEVEL <= 7;
    
    Monday   NLS First day of week 1 if day 1 = SUN, 0 if MON
    -------- --------------------- --------------------------
    31/12/12 31/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    

    Or it could be simpler:

    ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
    
    WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7)
    SELECT INPUT_DAY,
    TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label"
    from data;
    
    INPUT_DAY Day label
    --------- ------------------------------------
            1 SUNDAY
            2 MONDAY
            3 TUESDAY
            4 WEDNESDAY
            5 THURSDAY
            6 FRIDAY
            7 SATURDAY
    
    alter session set nls_territory = 'FRANCE';
    
    WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7)
    SELECT INPUT_DAY,
    TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label"
    from data;
    
    INPUT_DAY Day label
    --------- ------------------------------------
            1 MONDAY
            2 TUESDAY
            3 WEDNESDAY
            4 THURSDAY
            5 FRIDAY
            6 SATURDAY
            7 SUNDAY
    
  • How to get the current position from the point of view

    can I know how to get the current position of the view?

    Edited by: anIdiot July 27, 2011 22:01

    1 - get belvedere of the universe:

    u = new SimpleUniverse (canvas3D);
    ViewPlat = u.getViewingPlatform (); view of the universe

    definition viewplat: ViewingPlatform ViewPlat;

    2 - get look a transform of the platform in an existing Transform3D

    ViewPlat.getViewPlatformTransform () .getTransform (t3d).

    3 - Look at the trandform: t3d.get (Quater1, vector1); orientation object Get and coords

    Kind regards.
    JFP

  • How to get the name of the current PDF file?

    Hello world

    I know this is maybe a question has been asked millions of times, but I couldn't find a straight answer.

    I am using a workflow that comes with a Content Manager Solution is not Adobe this WF will generate a file very long (about 30 characters) name that will be used as the number of unique processes.

    To go to the step next in the workflow that I have to update the table in the database and registration update will use the process number.  What I did is that I added a field in hidden text in the form, which should have the number of processes on the initialize function.

    Now my question is how to get the file name of the opened PDF file?

    I'm sure that there is a function in JS, but I couldn't find the way to do it.

    Thanks in advance guys for help.

    Mazen

    Acrobat can create LiveCycle Design possible forms, but each uses a different and different languages or syntax approach.

    There are a number of ways to get the file name and path, urt getFileName.

Maybe you are looking for