Get the location of the device

I had my application built with HTML5 for OS7, I build for BB10 and I decided to go with a feel more native and waterfalls. I must admit however, the old WebWorks documentation was much wasier and friendly, you had a small example of using each feature.

I'm having a problem getting the location of the device, I went through the sample application "Diagnoses of the situation", but it's really complicated (he has 3 classes of objects with a ton of features to get the location).

I'm just trying to find the location of the device, using cell towers, every two minutes. I want to create and the entire class for this? Also, how to trigger this function of the part of Cascades?

I'd appreciate any help!

Hello

Here's a simplified example of code. These files are from the empty project template by default in the IDE of Momentix (file-> New-> project-> BlackBerry Project-> Application of stunts-> empty project Standard). They have been updated to include cellsite positioning updates every two minutes. The output will simply through cost.

applicationui.h:

// Default empty project template
#ifndef ApplicationUI_HPP_
#define ApplicationUI_HPP_

#include 

#include 

using ::QtMobilitySubset::QGeoPositionInfo;     // so the SIGNAL()/SLOT() macros can have matching signatures.

namespace bb { namespace cascades { class Application; }}

/*!
 * @brief Application pane object
 *
 *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class ApplicationUI : public QObject
{
    Q_OBJECT
public:
    ApplicationUI(bb::cascades::Application *app);
    virtual ~ApplicationUI() {}

    void startCellSiteUpdates();

public Q_SLOTS:
    void positionUpdated(const QGeoPositionInfo & pos);
    void positionUpdateTimeout();

private:
    QtMobilitySubset::QGeoPositionInfoSource * _source;
};

#endif /* ApplicationUI_HPP_ */

applicationui.cpp

// Default empty project template
#include "applicationui.hpp"

#include 

#include 
#include 
#include 

#include 

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject();
    // set created root object as a scene
    app->setScene(root);

    // Instantiate the default QGeoPositionInfoSource
    _source = QtMobilitySubset::QGeoPositionInfoSource::createDefaultSource(this);
    if ( _source ) {        // connect to the QGeoPositionInfoSource's signals, to get the position info and/or error status
        connect(_source, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this, SLOT(positionUpdated(const QGeoPositionInfo &)));
        connect(_source, SIGNAL(updateTimeout()), this, SLOT(positionUpdateTimeout()));
    }
}

// call this method to start the position updates
void ApplicationUI::startCellSiteUpdates()
{
    if ( !_source ) {

        std::cout << "Error getting default position info source" << std::endl;
        return;
    }

    // QtLocation allows control over which provider(s) will be queried for position info. NonSatellitePositioningMethods
    // includes wifi and cellsite fix types.
    _source->setPreferredPositioningMethods( QtMobilitySubset::QGeoPositionInfoSource::NonSatellitePositioningMethods );

    // On BlackBerry the default QGeoPositionInfoSource allows finer control over the fix type. This extension, and others, take advantage of the Qt property system.
    // Here we are interested only in cellsite fixes.
    _source->setProperty("fixType", "cellsite");

    // set the update interval to a couple of minutes.
    _source->setUpdateInterval(120000);

    // start the updates, which we expect to receive in ApplicationUI::positionUpdated()
    _source->startUpdates();
}
// slot connected to the QGeoPositionInfoSource::positionUpdated() signal
void ApplicationUI::positionUpdated(const QGeoPositionInfo & pos)
{
    // print out the position in a convenient format:
    std::cout << pos.coordinate().toString().toLatin1().constData() << std::endl;

    // print out the accuracy as well, if available
    if ( pos.hasAttribute(QtMobilitySubset::QGeoPositionInfo::HorizontalAccuracy) ) {
        std::cout << "    horizontal accuracy = " << (double)pos.attribute(QtMobilitySubset::QGeoPositionInfo::HorizontalAccuracy) << std::endl;
    }

}
// slot connected to the QGeoPositionInfoSource::updateTimeout() signal
void ApplicationUI::positionUpdateTimeout()
{
    std::cout << "timeout occurred" << std::endl;

    // On BlackBerry more information as to why the device timed out may be available:
    bb::location::PositionErrorCode::Type errorCode = bb::location::PositionErrorCode::None;

    if ( _source->property("replyErrorCode").isValid()  ) {
        errorCode = _source->property("replyErrorCode").value();
        if ( errorCode != bb::location::PositionErrorCode::None ) {
            std::cout << "    " << _source->property("replyErrStr").toString().toLatin1().constData() << std::endl;
        }
    }
}

And main.cpp looks like this:

// Default empty project template
#include 

#include 
#include 
#include "applicationui.hpp"

// include JS Debugger / CS Profiler enabler
// this feature is enabled by default in the debug build only
#include 

using namespace bb::cascades;

Q_DECL_EXPORT int main(int argc, char **argv)
{
    // this is where the server is started etc
    Application app(argc, argv);

    // localization support
    QTranslator translator;
    QString locale_string = QLocale().name();
    QString filename = QString( "SimpleLocation_%1" ).arg( locale_string );
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator( &translator );
    }

    ApplicationUI * appUI = new ApplicationUI(&app);

    appUI->startCellSiteUpdates();

    // we complete the transaction started in the app constructor and start the client event loop here
    return Application::exec();
    // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
}

Your file bar - descriptor.xml must contain this line to allow approval of the app for location-based services:

    access_location_services

Also to ensure that location-based Services are enabled under settings on your device.

Your .pro file should contain this line so that the QtLocationSubset library is linked:

LIBS += -lQtLocationSubset

I hope this helps!

Jim

Tags: BlackBerry Developers

Similar Questions

  • Attempt to sync music error - could not get the device certificate - C00D11E3

    Original title: C00D11E3

    I tried to sync music from my laptop to my brand new Sony Walkman NWZ - B153 MP3 player, but I got was a full load of a red cross on the left side of the lines of track information.

    "When I left clicked on one of the crosses, he said," cannot get the certificate of the device "whatever that means, more the C00D11E3 error code.

    I got a Sony's MP3 player before and I could download music o problem. So, why the problem with this brand new?

    Garry

    Hi Garry,

    (1) how you try to synchronize?

    (2) using any software provided by the manufacturer of the device to synchronize?

    Since you were able to synchronize your old MP3 player (from the same manufacturer) on the same computer, there will be some settings in the new MP3 player.

    Cannot get the device certificate, can indicate that the device is locked by the manufacturer.

    You can check with Sony to known problems

    http://eSupport.Sony.com/

    You can download Windows Mobile Device Center and check, for more information please visit the links below

    Synchronize music, photos, contacts, and calendars with a mobile device

    http://Windows.Microsoft.com/en-us/Windows7/sync-music-pictures-contacts-and-calendars-with-a-mobile-device

    Download Windows Mobile Device Center 6.1

    http://www.Microsoft.com/windowsmobile/en-us/downloads/Microsoft/Device-Center-download.mspx

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to get the device Diagnostic report?

    Hi guys.

    Do you know how to get the device Diagnostic report?

    Is this possible on a Simulator?

    Thank you.

    Hi guys.

    I found the way how to get.

    It's easy.

    In order to get the diagnostics test report, go to Options / settings-> Network Mobile-> select "diagnostic test" in the menu-> then 'run '.

  • How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    You can use this class: http://goo.gl/GtMLP for information on devices

    something like this:

    String myDeviceModel = android.os.Build.MODEL;
    String myDeviceBrand = android.os.Build.BRAND;
    String myDeviceDevice = android.os.Build.DEVICE;
    
  • How to get the device Pin code?

    Is Hello possible to get the BB device PIN in Android? Something similar to DeviceInfo.getDeviceid ()?

    Finally, I fixed all my problems.

    I had errors: TOO_MANY_REGISTRATIONS and SERVICE_NOT_AVAILABLE

    TOO_MANY_REGISTRATIONS is set by the phone factory reset. I seems that recording is not completely cleaned when I delete applications and restart the phone. Is there a solution to this? Some cleaning functions, I have not found in the software?

    SERVICE_NOT_AVAILABLE was inside the BlackBerry Simulator ever on the phone.

    Download the DevicePin:

    Use this 'Tutorial' https://developer.blackberry.com/developer/android/apisupport/creating_push-enabled_android_apps.htm... But download the GCM.jar with the Manager software development kit. To do this click "Obsolate" below and you will find the 'Google Cloud messaging for Android Library'. Put it in your make libs folder right click-> Add as library and put "compile files('libs/gcm.jar')' in your build.gradle

    If you now use the following code, you get the devicepin:

    GCMRegistrar.checkDevice(this);GCMRegistrar.checkManifest(this);GCMRegistrar.register(this, SENDER_ID); String regId = GCMRegistrar.getRegistrationId(this);
    
  • Get the device ID in the BpsSubscriptionMessageBuilder.createByteSubscriptionMessage method

    Hi all,

    First of all, sorry if this thread is not appropriate because there is a similar. If there is, I have not found.

    I want to build an application compatible with its server push, but I don't want to use servlets and the jar provided by push SDK service.

    I think that the only thing I have to do in the server part is to get the PAP message with the required parameter 'address' (the device) using low level libraries.

    However, I have a problem of developing the application in the device. Using this code as a reference:
    http://docs.BlackBerry.com/en/developers/deliverables/21128/Subscribe_to_a_BPS_content_provider_1226...

    I see that the parameter 'address' is obtained in the createByteSubscriptionMessage method, but I don't see its implementation to get the parameter 'address' (got to the servlet subscription) because it is a native method.

    Thus,.

    1 - see the API:

    http://www.BlackBerry.com/developers/docs/7.0.0api/NET/rim/device/API/IO/messaging/BpsSubscriptionMe...

    What is the parameter 'address' obtained in the server (servlet subscription) part? The device ID? How can I get it back?

    2 - I could build the app-client just stay at step 6 and send the HTTP message on my way?

    Can someone help me?

    Thank you all.
    Kind regards.

    If I understand what you're trying to ask is how to get the address of the device your application to initiator to push aside server.

    If so, you can see an example here:

    https://developer.BlackBerry.com/Java/documentation/registering_to_receive_push_messages.html

    Basically, you can see the code example in the sample application compatible push built a HTTP message to send to its application server-side. Although this example sends the HTTP message in the format SDK expects that you don't need to use the SDK or the same format, but you can follow the example to send a simple HTTP message on your own server to send the information about your application requires server-side. For example, the link above shows that to get the address of the device, you can do this:

    Integer.toHexString( DeviceInfo.getDeviceId() )
    

    In side your application server, you must save the address of the device, then when you build the push request message that you use as the address of the device if you are using the low level SDK APIs (or enter this value in the field address PAP XML if not not using the SDK).

  • How to get the device folder Structure?

    Hi all

    I'm new BB10 Native Development. Please help me to get the list of device folder Structure.

    like...

    books.

    camera.

    docuents

    downloads

    Misc

    music

    photos

    print

    protected_meda

    I want the same impression that I put here.

    Please, please share your exp.

    Thank you
    Pawan

    QDir::entryList (). Or maybe QDirIterator.

  • How to get the device Versions of OS on the device

    Hello

    I'm trying to get the exact device of the OS versions, I get as below

    07-30 12:39:31.842: I/System.out(76509407): HEIGHT720
    07-30 12:39:31.888: I/System.out(76509407): HI--2
    07-30 12:39:31.896: I/System.out(76509407): Device Software Version is>>>>01
    07-30 12:39:31.900: I/System.out(76509407): Release Version is2.3.3
    07-30 12:39:31.900: I/System.out(76509407): CODENAME Version isREL
    07-30 12:39:31.900: I/System.out(76509407): INCREMENTAL Version isplayer-2.0.0_dev.eng.SER
    07-30 12:39:31.900: I/System.out(76509407): SDK Version is10
    07-30 12:39:31.900: I/System.out(76509407): BOARD:SQR100-2
    07-30 12:39:31.900: I/System.out(76509407): BOOTLOADER:unknown
    07-30 12:39:31.900: I/System.out(76509407): BRAND:BlackBerry
    07-30 12:39:31.901: I/System.out(76509407): DEVICE:Q5
    07-30 12:39:31.901: I/System.out(76509407): FINGERPRINT:BlackBerry/BlackBerry/Q5:2.3.3/10.1.0.123/player-2.0.0_dev.eng.SER:user/test-keys
    07-30 12:39:31.901: I/System.out(76509407): HARDWARE:SQR100-2
    07-30 12:39:31.901: I/System.out(76509407): HOST:brx278cnc
    07-30 12:39:31.901: I/System.out(76509407): ID:10.1.0.123
    07-30 12:39:31.901: I/System.out(76509407): MANUFACTURER:RIM
    07-30 12:39:31.901: I/System.out(76509407): MODEL:Q5
    07-30 12:39:31.901: I/System.out(76509407): PRODUCT:BlackBerry
    07-30 12:39:31.902: I/System.out(76509407): SERIAL:0000000000072276751765
    07-30 12:39:31.902: I/System.out(76509407): TAGS:test-keys
    07-30 12:39:31.902: I/System.out(76509407): TIME:1368606268000
    07-30 12:39:31.902: I/System.out(76509407): TYPE:user
    07-30 12:39:31.902: I/System.out(76509407): OS Version is:8.0.0
    07-30 12:39:31.902: I/System.out(76509407): getDeviceName isRIM Q5
    -------------------------------------------------------------------------
    07-30 18:15:27.008: I/System.out(40493276): HEIGHT1280
    07-30 18:15:27.052: I/System.out(40493276): HI--3
    07-30 18:15:27.059: I/System.out(40493276): Device Software Version is>>>>null
    07-30 18:15:27.064: I/System.out(40493276): Release Version is2.3.3
    07-30 18:15:27.064: I/System.out(40493276): CODENAME Version isREL
    07-30 18:15:27.065: I/System.out(40493276): INCREMENTAL Version isplayer-2.0.0_dev.eng.SER
    07-30 18:15:27.065: I/System.out(40493276): SDK Version is10
    07-30 18:15:27.065: I/System.out(40493276): BOARD:unknown
    07-30 18:15:27.065: I/System.out(40493276): BOOTLOADER:unknown
    07-30 18:15:27.065: I/System.out(40493276): BRAND:BlackBerry
    07-30 18:15:27.065: I/System.out(40493276): DEVICE:Z10
    07-30 18:15:27.065: I/System.out(40493276): FINGERPRINT:BlackBerry/BlackBerry/Z10:2.3.3/10.0.0.279/player-2.0.0_dev.eng.SER:user/test-keys
    07-30 18:15:27.065: I/System.out(40493276): HARDWARE:unknown
    07-30 18:15:27.065: I/System.out(40493276): HOST:brx278cnc
    07-30 18:15:27.065: I/System.out(40493276): ID:10.0.0.279
    07-30 18:15:27.065: I/System.out(40493276): MANUFACTURER:RIM
    07-30 18:15:27.065: I/System.out(40493276): MODEL:Z10
    07-30 18:15:27.066: I/System.out(40493276): PRODUCT:BlackBerry
    07-30 18:15:27.066: I/System.out(40493276): SERIAL:unknown
    07-30 18:15:27.066: I/System.out(40493276): TAGS:test-keys
    07-30 18:15:27.066: I/System.out(40493276): TIME:1357852772000
    07-30 18:15:27.066: I/System.out(40493276): TYPE:user
    07-30 18:15:27.067: I/System.out(40493276): OS Version is:8.0.0
    07-30 18:15:27.067: I/System.out(40493276): getDeviceName isRIM Z10
    07-30 18:15:27.264: I/QNXNavigatorClient(12779732): PackagesOpenedRunnable: [com.XXX]
    07-30 18:15:27.433: I/ActivityManager(12779732): Displayed com.XXX/.LoginActivity: +701ms
    

    Is there any API to be called for versions during extraction device OS, more relevant that I find is ID info, which is also coming as well as fingerprints which is not accurate

    He didn't give me specific appliance OS, my Version of the OS version is 10.0.9.2732. (z10) and Q5 (10.1.0.2342)

    Someone at - he noticed this problem? I have

    Thank you

    Rakesh

    The /etc/os.version is the full path, there are default.

    You can simply use your preferred method to read files, something like this:

    File = new File("/etc/os.version");
    BufferedReader br is new BufferedReader (new FileReader (file));.
    String osVersion = br. ReadLine;

  • Method to get the device ID

    Hi experts,

    Can you kindly mention the method by which I can get the BB device ID using J2ME.

    net.rim.device.api.system.DeviceInfo
    
    DeviceInfo.getDeviceId();
    
  • Get the device UID (naa) in the data store

    Hello

    I want to get the UID (naa) device from a data store (VcHostDatastoreSystem).

    But I don't seem to find it.

    Can someone help me with this?

    Kind regards

    Jonathan

    Look at the code in this post: receive information from scsi to a data store if the data store is known

    I used that as a starting point for the following... I put this code in a script task and passed in a VC:HostSystem object named "wfHostObject":

    for each (var lun in wfHostObject.configManager.storageSystem.storageDeviceInfo.multipathInfo.lun) {
        for each (var path in lun.path) {
            if (path.state == "active") {
                // Get the mountinfo
                for each (var mount in wfHostObject.configManager.storageSystem.fileSystemVolumeInfo.mountInfo) {
                    if (mount.volume.hasOwnProperty("extent")) {
                        for each (var extent in mount.volume.extent) {
                            var tmp = extent.diskName.split(/\./);
                            var regExp = new RegExp(tmp[1],'gi');
                            if (lun.id.match(regExp)) {
                                System.debug("=========== Mount Name: "+mount.volume.name);
      System.debug("Type: "+mount.volume.type);
                                System.debug("Extent diskName: "+extent.diskName);
      System.debug("vStorageSupport: "+mount.vStorageSupport);
      System.debug("---- Mount Info");
      var mountInfo = mount.mountInfo;
      System.debug("AccessMode: "+mountInfo.accessMode);
      System.debug("Accessible: "+mountInfo.accessible);
      System.debug("Inaccessible Reason: "+mountInfo.inaccessibleReason);
      System.debug("Mounted: "+mountInfo.mounted);
      System.debug("Path: "+mountInfo.path);
                            }
                        }
                    }
                }
            }
        }
    }
    

    Example of output:

    [2013-12-12 17:03:57.370] [D] =========== Mount Name: qnap-iscsi
    [2013-12-12 17:03:57.370] [D] Type: VMFS
    [2013-12-12 17:03:57.370] [D] Extent diskName: naa.60014055dbf2832dbc91d4bacdb356d9
    [2013-12-12 17:03:57.370] [D] vStorageSupport: vStorageSupported
    [2013-12-12 17:03:57.370] [D] ---- Mount Info
    [2013-12-12 17:03:57.374] [D] AccessMode: readWrite
    [2013-12-12 17:03:57.374] [D] Accessible: true
    [2013-12-12 17:03:57.374] [D] Inaccessible Reason: null
    [2013-12-12 17:03:57.374] [D] Mounted: true
    [2013-12-12 17:03:57.374] [D] Path: /vmfs/volumes/528cbe4f-6ae388d8-6a9e-14dae927d5bb
    
  • How can I get the device driver for Dell all-in-one 944

    I got a new PC and don't have the information to use my printer.  How to get the driver from Dell for this printer info

    ... How to get the driver from Dell for this printer info

    I have moved your post in the comments to the Windows, hardware and drivers section section, but have no idea which version of Windows that you are operating on. If your printer is compatible with the version of Windows you are using, you can download the drivers and support the Dell 944 all-in-one printer from Dell heresite software.
                                                   
    You mentioned that you have a new PC, so it is likely that you use one of the Windows 7 64-bit editions. If you want to check the hardware compatibility with Windows 7, you should try the Windows 7 Compatibility Center.

    Edit: If you try to work around a problem of incompatibility of Windows 7, there's a solution posted in the following thread,

  • How can I get the drivers for xp usb / get the device can run faster in the listed ports

    POP UP WITH SAYING HIS DEVICE CAN RUN FASTER IN THE PORTS LISTED, I HAVE THE WIRELESS CARD WIRELESS, MOUSE AND SPRINT U600, CONNECTED TO THE LAPTOP, THE PROBLEM JUST STARTED

    See the discussion of the difference between USB 1.1 and USB 2.0 and why this error message http://ask-leo.com/what_does_the_usb_device_can_perform_faster_mean.html
    If you have an old computer, you do not all USB 2.0 ports or some of your USB ports may be 1.1 e.a. 2.0

    Open the Device Manager (start > run > devmgmt.msc > OK) and expand the "Controllers of Bus USB" section by clicking on the + sign to the left.

    Are there warning icons? If so, provide details

    It will probably take several entries for "PCI to USB Host Controller" or similar terms.  Please report if one (or several) of these entries are for a "PCI to USB Enhanced Host Controller.  If none of the USB controllers is "strengthened", you do not have USB 2.0

  • How do we get the device phone number using webworks api 2.0

    I could see an example of code to get the phone number of javascript which is not supported for BB10.  The code below does not work for BB10? If so, what is one alternative to the native extension.

    
    

    Hi beats,

    It is currently not possible. The only way you could get the phone number in this moment is to create a native extension that accesses the 'phone' / 'Line' API here http://developer.blackberry.com/native/reference/cascades/bb__system__phone__line.html?f=line#functi...

  • Cannot get the device certificate

    This is a new walkman NWZ-E473. I was able to transfer these WMA files on my walkman older. What can I do to fix this device certificate?

    Mary,

    WMA file you are trying to transfer seems to be management of digital rights (DRM) protected. DRM-protected files cannot be transferred to the Walkman player.

    If my post answered your question, please mark it as "acceptable Solution".

    Thank you for your message.

  • Use iCloud with BMW connected drive... How to get the device recognized by the connected player.

    Using iCloud email with BMW connected drive... How do I get my Apple ID and PW recognized by the BMW connected drive online?

    See here - How do I add iCloud email to the connected reader

  • Get the device USB-5133 by program number

    I build systems integrated with many USB devices USB.

    All the regular USB DAQ device number can be detected programmatically.

    My USB-5133 (digitizer high speed) is not detected by program, by a feature in Labview.

    I need this tool to communicate with my systems without manually selecting device number before running my application.

    Hi Harold,.

    Thanks for posting your question. Please check the following knowledge base

    Best regards

    Faris

Maybe you are looking for