Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 29
Registered: ‎08-03-2014
My Device: Q10
My Carrier: Vodafone
Accepted Solution

Get Contact Details From InvokeRequest

I am trying to get contact details when share contact has been chosen from contacts and my app has been invoked.

 

onInvoked is being called but I can't figure out how to get the Contact from the InvokeRequest I receive as an argument.

 

This is what I have tried..

 

void ApplicationUI::onInvoked(const bb::system::InvokeRequest& invoke)
{
    qDebug() << "oninvoked";
    Contact contact;
    ContactService cs;
    cs.contactFromVCard(QString(invoke.data()));
    qDebug() << "name: " << contact.displayName();


}

 

But it seems to be wrong, how do I accomplish what I am trying to do?

Developer
Posts: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Get Contact Details From InvokeRequest

[ Edited ]

If you call uri() then you can see the URL to local file

 

request.uri()

 This can be transformed to path to local file:

request.uri().toLocalFile()

 Now all you need is open the file and get all your data

 

    QString localpath = request.uri().toLocalFile();
    qDebug() << "localpath = " << localpath;
    QFile file(localpath);
    if (file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
       QTextStream in(&file);
       while (!in.atEnd()) {
          QString line = in.readLine();
          qDebug() << line;
       }
    }

 It may be not the perfect solution but it should work Smiley Happy