Update the title bar or something when NFC Message received (HELP!)

I send you a message using NFC. I want to update the title bar title whenever my application receives a message. Code does not work.

I use the example of receiver NFC of GitHub with some modifications.

Any ideas why it does not work? In addition, no idea where I would add code to trigger another method, as soon as the new payload is received?

main.cpp

 

/* Copyright (c) 2012, 2013  BlackBerry Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "NfcReceiver.hpp"

#include 
#include 
#include 
#include 

#include 
#include 

using namespace bb::cascades;

Q_DECL_EXPORT int main(int argc, char **argv)
{
    Application app(argc, argv);

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

//! [0]
    NfcReceiver nfcReceiver;

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);
    qml->setContextProperty("_nfcReceiver", &nfcReceiver);

//! [0]

    AbstractPane *root = qml->createRootObject();

    //set objects
    TitleBar* tb = new TitleBar();
    tb = root->findChild("titleBar");

    Application::instance()->setScene(root);

    return Application::exec();
}

NfcReceiver.cpp

/* Copyright (c) 2012, 2013  BlackBerry Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "NfcReceiver.hpp"

#include 
#include 
#include 
#include 

//! [0]
NfcReceiver::NfcReceiver(QObject *parent)
    : QObject(parent)
    , m_messageRecords(new bb::cascades::QVariantListDataModel()),
    //THIS PART BELOW. NOT SURE IF I AM DOING SOMETHING RIGHT OR WRONG NEED TO EXPOSE tb contextProperty to this class...
    tb(new bb::cascades::TitleBar())
{
    m_messageRecords->setParent(this);
    tb->setParent(this);

    // Create an InvokeManager
    bb::system::InvokeManager *invokeManager = new bb::system::InvokeManager(this);

    /**
     * The signal invoked(const bb::system::InvokeRequest&) is used for applications.
     */
    bool ok = connect(invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)),
                      this, SLOT(receivedInvokeTarget(const bb::system::InvokeRequest&)));
    Q_ASSERT(ok);
    Q_UNUSED(ok);

}
//! [0]

//! [1]
void NfcReceiver::receivedInvokeTarget(const bb::system::InvokeRequest& request)
{
    // The data contains our NDEF message
    const QByteArray data = request.data();

    // Create out NDEF message
    const QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage::fromByteArray(data);

    // Fill the model with the single records
    m_messageRecords->clear();

    for (int i = 0; i < ndefMessage.size(); ++i) {
        const QtMobilitySubset::QNdefRecord record = ndefMessage.at(i);

        QVariantMap entry;
        entry["tnfType"] = record.typeNameFormat();
        entry["recordType"] = QString::fromLatin1(record.type());
        entry["payload"] = QString::fromLatin1(record.payload());
        entry["hexPayload"] = QString::fromLatin1(record.payload().toHex());

        m_messageRecords->append(entry);

    }

    emit messageReceived();

    //set titlebar title // this is failing... :(
    setTitle();

}
//! [1]

bb::cascades::DataModel* NfcReceiver::messageRecords() const
{
    return m_messageRecords;
}

void NfcReceiver::setTitle(){
    tb->setTitle("boo");
}

 

NfcReceiver.hpp

/* Copyright (c) 2012, 2013  BlackBerry Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef NFCRECEIVER_HPP
#define NFCRECEIVER_HPP

#include 

#include 
#include 
#include 
#include 
namespace bb { namespace cascades { class Application; }}

/*!
 * @brief A helper class that encapsulates the code to receive a NDEF message.
 */
class NfcReceiver : public QObject
{
    Q_OBJECT

    // A property to make the received NDEF message records available to the UI
    Q_PROPERTY(bb::cascades::DataModel* messageRecords READ messageRecords CONSTANT)

public:
    /**
     * Creates a new NFC receiver object.
     *
     * @param parent The parent object.
     */
    NfcReceiver(QObject *parent = 0);

Q_SIGNALS:
    // This signal is emitted whenever a new NDEF message has been received
    void messageReceived();

private Q_SLOTS:
    // This slot is invoked whenever the InvokeManager detects an invocation request for this application
    void receivedInvokeTarget(const bb::system::InvokeRequest& request);
    // SET TITLE
    Q_INVOKABLE void setTitle();
private:
    // The accessor method of the property
    bb::cascades::DataModel* messageRecords() const;

    // The model that contains the records of the received NDEF message
    bb::cascades::QVariantListDataModel* m_messageRecords;

    //NOT SURE IF I AM EXPOSING THE TITLEBAR CORRECTLY HERE
    bb::cascades::TitleBar* tb;
};

#endif

hand. QML

 

/* Copyright (c) 2012, 2013  BlackBerry Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import bb.cascades 1.0

Page {
    titleBar: TitleBar {
        id: t
        objectName: "titleBar"
        title: "awesome"
    }
    Container {
        layout: StackLayout {
            orientation: LayoutOrientation.TopToBottom
        }

        // The background image
       /* ImageView {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill

            imageSource: "asset:///images/background.png"
        }*/

        //! [0]
        // The list view that shows the records of the received NDEF message
        ListView {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill

            dataModel: _nfcReceiver.messageRecords

            listItemComponents: [

                ListItemComponent {

                    type: ""

                    Container {
                        preferredWidth: 768
                        leftPadding: 10
                        rightPadding: 10

                        Field {
                            title: qsTr("tnf type")
                            value: ListItemData.tnfType == "0" ? qsTr("Empty Tag") :
                                   ListItemData.tnfType == "1" ? qsTr("Well Known Type") :
                                   ListItemData.tnfType == "2" ? qsTr("Media (MIME)") :
                                   ListItemData.tnfType == "3" ? qsTr("Uri") :
                                   ListItemData.tnfType == "4" ? qsTr("External") : ""
                        }

                        Field {
                            title: qsTr("record type")
                            value: ListItemData.recordType == "Sp" ? qsTr("Smart Poster") :
                                   ListItemData.recordType == "T" ? qsTr("Text") :
                                   ListItemData.recordType == "U" ? qsTr("Uri") :
                                   ListItemData.recordType == "Gc" ? qsTr("Generic Control") :
                                   ListItemData.recordType == "Hr" ? qsTr("Handover Request") :
                                   ListItemData.recordType == "Hs" ? qsTr("Handover Select") :
                                   ListItemData.recordType == "Hc" ? qsTr("Handover Carrier") :
                                   ListItemData.recordType == "Sig" ? qsTr("Signature") : ""
                        }

                        Field {
                            title: qsTr("payload")
                            value: ListItemData.payload
                        }

                        Field {
                            title: qsTr("hex")
                            value: ListItemData.hexPayload
                        }
                    }
                }
            ]
        }//end listview
        Label{
            // I WANT TO GET THE PAYLOAD AND PARSE IT IN A CUSTOM WAY HERE....
            id: parsedText
            text: ""
            textStyle.fontSize: FontSize.XXLarge
            textStyle.color: Color.Black

        }
        //! [0]
    }
}

 

I'm just trying to help here. What does not work is I looked at your code and I looked at my code and I do not have a reference point on what parts do what...

I want to respond in a tough manner and does not help when I'm obviously confused on the implementation and the instructions are not clear. The documentation is written for someone who has already worked with NFC and protocols, not beginners wishing to implement NFC functionality in the application.

Based on this kind of response, I'll just leave NFC functionality out of my application.

Tags: BlackBerry Developers

Similar Questions

  • Change the title bar text

    Hello
    I want to change the name that appears in the title bar for my generated chm file.

    How can I change the text that appears in the title bar. I tried the file > rename project and file > settings of the project but by changing the titles here does not affect what appears in the title bar.

    Thanks in advance for your help

    Pass the field "legend of the window" properties of the window. It is set by deafult when a project is created but is not changed if you rename.

  • Why the title bar on Firefox and the Windows 7 taskbar let distorted image when a list of folders crosses one or the other?

    I use a lot of folders in my bookmarks list. I noticed that with AMD and Nvidia cards based on video, that if I use a folder in my bookmarks list that a lot, a lot of bookmarks, the bookmark list will cross the box title bar of Firefox and the taskbar in Windows 7 and down. When this happens, the title bar on Firefox versions 8-10 and the taskbar at the bottom let images from the list of bookmarks which do not disappear (at least that I have use F11 mode full screen to clear away from the image and bring it back to normal). If I use a Matrox video card, it doesn't. Why is this?

    Try turning off hardware acceleration.

    • Tools > Options > advanced > General > Browsing: "use hardware acceleration when available.

    If disable hardware acceleration works then check if there is an update available for your graphics display driver.

  • Tabs are not in the title bar even when the window is maximized Windows

    If I'm right, given that shponkah 4 b 9 FFX must be in the title bar when the ffx window is maximized on Windows operating system. [https://bugzilla.mozilla.org/show_bug.cgi?id=572160]
    I'm on XP Pro
    It works fine on the minefield for me.
    But in FFX 4 b 9 and 4b 10... tabs are always under the Firefox logo...

    Did you set up using the (bar of tabs above) option "Tabs at the top". Right-click on a toolbar to display the list of toolbars and make sure "Tabs at the top" is selected.

  • Strange (Chinese) characters displayed in the title bar

    From last 3-4 days I get some strange Chinese characters on top of the title bar or open tabs. They can not be selected by mouse and arrow sometimes (like enter key) is indicated on each tab.
    It's random, means that there is not any special condition when they appear.

    I have reset (all) Firefox, authorized cash, remove all the unknown, having no other than adobe pdf (not compatible) extension.

    I checked for anything installed within the last few days, but there is nothing installed despite updates windows and Firefox (34.0)
    I use windows 8.1. Please check the screenshot for exactly the problem.

    Did you disable or uninstall the McAfee SiteAdvisor?

    The extension of McAfee SiteAdvisor has been reported to cause problems with Chinese characters (CJK) text on the tabs, so that you can disable this extension.

    See also these SUMO son:

  • How to change the color of the title bar on an application?

    Original title: Windows title bar

    I use Windows Vista Ultimate on a Sony Vaio. I've customized my Windows Vista Basic theme so that my title bar was black. I don't know what happened all of a sudden today. A program called HP Update did something and the title bar changed suddenly light blue and I can't change it back! Everything was fine before. Help!

    Hello

    In native mode, change the title bar, you do not use the Vista theme. Check under personalisation/themes to see if updating is returned to the system in this mode. If so, change it to a standard theme. Once in the standard theme, you should be able to change the color of title bar (and others) in the classic appearance properties.

    If you are using a count of third-party product to change the user interface, you will need to consult with the support for this product.

    Good luck, Rick Rogers, aka "Crazy" - Microsoft MVP http://mvp.support.microsoft.com Windows help - www.rickrogers.org

  • Two monitors: right of the title bar part cannot be moved

    Hi Ho

    When I use two monitors in landscape mode (monitor extends the desktop of the screen from left to right), a part of the title bar of the program and windows Explorer is not responding. This does not happen when I use a single monitor. Since I use windows explore pillar-shaped, it is quite annoying, because I need to aim the small area that is still sensitive to drag a window exactly.

    The area on which is the upper right, just next door to reduce, enlarge, close buttons. Note that the thin strip under these buttons is responive above the entire title bar. Here is a picture of clarification:

    http://S27.postimg.org/kvhswknoz/windows_title_bar.jpg

    I've marked the sensitive area with the blue wire, the area on which the red. My windows are much thinner. The area on which remains the same size, regardless of the width of the window.

    I use Windows 7 pro, with almost the latest updates.  My left monitor is plugged as number 2, but is set as the main monitor. This is why the task bar on the left monitor.

    OK, I found the culprit.

    Is AMD Hydravision (the title of the Startup items) that is causing the problem. But I had to disable the Catalsyst control center as well, because this would reactivate Hydravision automatically during startup.

    Thank you, Sandy, for your help.

    To resolve the problem, run msconfig, activate the Startup tab and disable the AMD Hydravision and Catalyst Control Center.

  • Added drop-down list for the title bar

    Hi - I want to add a menu component from the 'title bar ' of my application.  Something very similar to that implemented in the Poynt application.

    I already gave up to use something similar to setTitle and have a horizontalFieldManager added to my request before I add a vertical Manager.  First, I added a label to my horizontal Manager field and that works fine, but when I tried (to test) to add an ObjectChoiceField he appeared on the next vertical row, not next to my text.  I'm quite lost when it comes to customize aspects of the UI of my BB apps.

    I suspect that the problem here is that, by default, the ObjectChoiceField will use the entire width.  You should limit its width, by substituting the layout and getPreferredWidth for the ObjectChoiceField.  Memory, a LabelField, will ask only for the width it needs.

    Here is an example that puts a DateField and an ObjectChoiceField in the title area.  I hope you can rework to meet your requirement.

    HorizontalFieldManager hfm = new HorizontalFieldManager();
    hfm.add(new DateField("Some Text: ",  System.currentTimeMillis(),
                    DateFormat.getInstance(DateFormat.TIME_DEFAULT)) {
        public int getPreferredWidth() {
            return 150;
        }
        protected void layout(int width, int height)  {
            super.layout(getPreferredWidth(), height);
        }
    });
    hfm.add(new ObjectChoiceField(" ",new String[]{"some", "text"} ));
    setTitle(hfm);
    
  • How to put a small icon in the title bar of the main screen

    Hi all, I'm new to the BlackBerry Forum.

    I can display a small icon in the title bar in the main Blackberry screen to warn users when my application is received something and it is reduced?

    Thanks in advance!

    Yes you can do this by using the following code.

    ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance();                EncodedImage image = EncodedImage.getEncodedImageResource("Indicator.png");            ApplicationIcon icon = new ApplicationIcon( image );            indicator = reg.register( icon, false, true);            indicator.setIcon(icon);            indicator.setVisible(true);
    
  • How to change the font of the title bar of the JFrame icon context menu?

    Hello world.

    I want to know how to change the font of the text that appears in the context menu is native to click with the right button on the icon that is completely left in the title bar of JFrames which use the default appearance for decoration (JFrame.setDefaultLookAndFeelDecorated (true); / / uses the metal L & F, theme "Océans").

    I searched and found nothing. I thought I could use what I learned to https://forums.oracle.com/message/9221826, but I couldn't find something that worked.

    Thanks to advance.t

    After a few more messing around, I finally did! I love so much it makes me a little sad Java how it is difficult to do things like that. In any case, I found a method here to recursively change the fonts of all components in a JFileChooser, but it does not work on the JPopupMenu (now I know the name) who jumps to the top of the icon in the title bar. So I messed around with this method a few casting and was able to change the fonts of the JMenuItems:

    public static void setSubComponentFont (Component comp[], Font font) {
        for (int x = 0; x < comp.length; x++) {
            if (comp[x] instanceof Container) {
                setSubComponentFont(((Container)comp[x]).getComponents(), font);
            }
            try {
                //comp[x].setFont(font);
                if (comp[x].toString().contains("JMenu")) {
                    for (Component y : ((JMenu)comp[x]).getPopupMenu().getComponents()) {
                        if (y.toString().contains("JMenu")) {
                            y.setFont(font);
                        }
                    }
                }
            } catch (Exception ex) {}
        }
    }
    

    I was inspired by this thread of utiliser.toString () .contains ().

    I also did with nested loops, so the path to the menu items can be seen:

    for (Component a : frame.getLayeredPane().getComponents()) {
        System.out.println(a.toString());
        if (a.toString().contains("MetalTitlePane")) {
            for (Component b : ((Container)a).getComponents()) {
                System.out.println(b.toString());
                if (b.toString().contains("SystemMenuBar")) {
                    for (Component c : ((Container)b).getComponents()) {
                        System.out.println(c.toString());
                        for (Component d : ((JMenu)c).getPopupMenu().getComponents()) {
                            System.out.println(d.toString());
                            if (d.toString().contains("JMenu")) {
                                d.setFont(font);
                            }
                        }
                    }
                }
            }
        }
    }
    

    Each System.out.println () gives an indication of what should go on what follows if State, so they should be used one at a time. This does not work for the title of the JFileChooser however font. When I have time I'll either look no further away inside or ask another question.

    So, if someone else needs like I did, it's here. As a tip, System.out.println () and. toString() are your friends! That's how I learned what was contained in each object, and which path I needed to take to get to objects of interest.

    Thanks anyway!

  • Acrobat XI, osx lion mountain, view full screen still has the title bar

    With acrobat X, when you went to the mode full-screen, it would use the full screen. While I am disappointed that the acrobat xi osx version does not use the native osx fullscreen option, now, however, when you enter full screen, it always seems to be a title bar of the window in full screen (with the dots on the left and the name of the file in the center of the title bar). I have not found a way to disable this option in the preferences. Is this the new normal?

    Thank you.

    [go to forum problem Installation & update Acrobat]

    We are aware of this issue and a bug has been connected (3203906).  There is no ETA at this time for when this can be resolved.

    We are sorry for the inconvenience.

    -David

  • How to restore the title bar? Title of the page displays only the tabs - this is not good enough

    I'm used to be able to see the title of the page in the title bar. Firefox has removed this feature, and now I have to mouse over the tab to display the title of the page. It is another example of extracting the characteristics that people use for reasons that I don't understand. So far, I had to install two 'add ons' to restore the common features on previous versions - and always on IE and Chrome.

    1. Right-click on a zone empty of the tab bar and select Customize.
    2. Click the button on the title bar in the lower left corner.
    3. Click the Customize output button when finished.
  • I'm visually impaired, and due to changes in UI v29, I see is no longer the menu bar where it is hidden in the title bar. How can I move it back to where it belongs?

    I have two computers at home and their improved to 29 of Firefox not knowing it contained UI heavy Exchange. I use the menu, bar and it is now superimposed on the title bar, where due to a visual disability, I can no longer see. Both systems have contrasting colors lit (white on a black background - forget Aero and trick themes), and Firefox is configured to use the system colors.

    Prior to version 29, the menu bar has white text on a black background. now it's on a background of colorful and almost completely invisible to me. The expansion is via the Windows Magnifier and Magnifier added to some Microsoft mouse top of range.

    As you can see on a brand new Virgin of installation of Firefox, no addons, no pre-existing profile, version 29 puts the menu bar on the taskbar. And Firefox, set up as I have, on a configured system with contrasting colors (black in my case) enabled, Firefox is unthemeable.

    But no matter, I Solver this myself. I started in XP and not update Firefox to find a new addon named "Classic theme restaurant" Who did the trick. This mark as resolved. But...

    I wish (not just Firefox) developers who want to fancy to the top of their interfaces would think how it would affect people with visual impairments. We use computers too.

  • do not see the title bar

    I'm not able to see the title bar. I have Firefox 16.01. I have Android 4.03. This is a new installation. Is hardly visible since its installation. I can't find an option to turn off this active or disabled in settings.

    The title of the page should appear in the "Awesomebar" when it is not actively used for the URL or search. You never see it?

  • Why there is no site title in the title bar of Firefox?

    I ' v just upgraded to Firefox 5, and there is no site title in the title bar of Firefox, as it used to be in point 3.6. What I have to turn somewhere in the options, or is it something else?
    Thanks in advance!

    You don't see the title in the title bat if the menu bar is hidden (view > toolbars) and the Firefox orange button.

    • Press F10, or press the Alt key to bring up the 'Menu Bar' temporarily if the menu bar is hidden.
    • Use "Firefox > Options ' if the menu bar is hidden.

    You can watch this extension.

Maybe you are looking for

  • Problem with iMessage

    I noticed after the update today with ios 10. Sometimes this iMessage stops working when I send to a friend and does not send or send text. I have not had any problems until today. It seems to be related to the new features. I have to restart my ipho

  • Firefox opens always 2nd tab to connect Yahoo

    I had to reset Firefox to try to solve another problem of software (which he did not set BTW) and after the reboot everytime I open Firefox, I get a 2nd tab for Yahoo asking me to connect to my Yahoo account even if I never disconnect. I have check t

  • T61 and Nokia Pc Suite, bluetooth not found

    My T61 has bluetooth installed correctly, but Nokia PC Suite can not found this bluetooth device. I reinstalled the drivers Pc Suite and bt, and I also tried with bt-windows drivers. PC suite gives an error message: "cannot find the type of connectio

  • Can not access the system restore.

    After the removal of a virus, no visible icons on desktop except Mcafee on the toolbar at the bottom.  Was able to access the internet by clicking on Mcafee and then update.  When you click Start the only visible program is Mcafee.  Cannot see the co

  • Windows safe mode

    I am running Windows Vista and my PC won't start in safe mode.  I tried all sorts of things, including the restore points, antivirus, etc.  I'm trying to get, for once, go to normal mode, so I can transfer files on an external hard drive, so I can up