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
Contributor
abang_adit
Posts: 27
Registered: ‎07-26-2012
My Device: i dont have a blackberry device
My Carrier: i dont have a blackberry device

Invoke addcontact from qml

Dear All,

i have some problem during using bb.action.ADDTOCONTACT

i already use invoke open browser, email , and dial and its work well

but i can't use addtocontact

this is my code

 

onClicked: {
                //invoke.trigger("bb.action.OPEN")
                invokeQueryaddcontact.data = "087872183913"
                invokeQueryaddcontact.updateQuery()
            }
            attachedObjects: [
	           Invocation {
		        id: invokeaddcontact
		        property bool auto_trigger: false
		            query: InvokeQuery {
		                id: invokeQueryaddcontact
		                invokeTargetId: "sys.pim.contacts.app"
		                mimeType: "application/vnd.blackberry.string.phone"
		                //uri: "http://www.google.com"
		            }
					onArmed: {
					    if (auto_trigger)
					        trigger("bb.action.ADDTOCONTACT")
					    auto_trigger = true;
					    
					}
		        }
            ]

 please help me

best regards,
aditya eka putra (@abang_adit)
Please use plain text.
New Developer
MarkS3
Posts: 8
Registered: ‎01-22-2013
My Device: Playbook
My Carrier: Rogers

Re: Invoke addcontact from qml

I am also having trouble with bb.action.ADDTOCONTACT 

 

Trying to use it in C++

 

InvokeRequest cardRequest;
QVariantMap data = QVariantMap();

 

data["phone"] = m_formattedNumber;
cardRequest.setTarget("sys.pim.contacts.app");
cardRequest.setAction("bb.action.ADDTOCONTACT");
cardRequest.setMimeType("application/vnd.blackberry.string.phone");
QByteArray encData = PpsObject::encode(data);
cardRequest.setData(encData);
InvokeTargetReply* reply = m_invokeManager-> invoke(cardRequest);

 

Also tried the phone number not encoded:

 

cardRequest.setData(m_formattedNumber.toUtf8());

 

In either case I just get the card flashed on the screen then disappears with no error reported.  Can't find any examples or documentation except the one page that lists the invocation parameters (https://developer.blackberry.com/cascades/documentation/device_platform/invocation/contacts.html)

 

Help!

 

Thanks! 

 

 

 

 

Please use plain text.
Developer
dkonigs
Posts: 247
Registered: ‎07-25-2008
My Device: Bold 9900

Re: Invoke addcontact from qml

Invoking the full contacts app to add a phone number, like you showed, is supposed to work.  However, when I've tried it, the contacts app actually crashes.  There is a bug written about this:

https://www.blackberry.com/jira/browse/BBTEN-1073

 

However, you can invoke the contacts card, with similar parameters, and it does work:

 

    bb::system::InvokeManager invokeManager;
    bb::system::InvokeRequest request;
    request.setTarget("sys.pim.contacts.card.picker");
    request.setAction("bb.action.ADDTOCONTACT");
    request.setMimeType("application/vnd.blackberry.string.phone");
    request.setData(m_formattedNumber.toUtf8());
    invokeManager.invoke(request);
Please use plain text.
New Developer
MarkS3
Posts: 8
Registered: ‎01-22-2013
My Device: Playbook
My Carrier: Rogers

Re: Invoke addcontact from qml

Thanks, works great now!  Your help is much appreciated in solving this perplexing issue!

Please use plain text.