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
Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

How do you use callUpdated to listen for Phone Calls

Does anyone have a piece of c++ code that shows how to listen for the signal Phone.callUpdated.  I want to do something when  a call is received but not sure how to set up for it. Thanks.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: How do you use callUpdated to listen for Phone Calls

I'm not sure of this, but give it a try Smiley Wink

 

Phone phone;

connect(phone, SIGNAL(callUpdated(Call*)), this, SLOT(doSomething(Call*)));

 And then write the method doSomething(Call *call).

______________________________________________________
BB10-OAuth: GitHub
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How do you use callUpdated to listen for Phone Calls

[ Edited ]

Parameter types in signals should be fully-qualified:

 

bool success = connect(phone,
                    SIGNAL(callUpdated(bb::system::phone::Call&)),
                    this,
                    SLOT(onCallUpdated(bb::system::phone::Call&)));

 

This page has a nice overview of Telephony API with links to samples:

https://developer.blackberry.com/cascades/documentation/device_comm/phone/

 

And the Phone class:

https://developer.blackberry.com/cascades/reference/bb__system__phone__phone.html

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: How do you use callUpdated to listen for Phone Calls

Not if you use Smiley Happy

 

using namespace bb::system::phone;
______________________________________________________
BB10-OAuth: GitHub
Highlighted
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How do you use callUpdated to listen for Phone Calls

MOC ignores "using namespace". Quoting Qt docs:

 

When checking the signatures of its arguments, QObject::connect() compares the data types literally. Thus, Alignment and Qt::Alignment are treated as two distinct types. To work around this limitation, make sure to fully qualify the data types when declaring signals and slots, and when establishing connections.


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: How do you use callUpdated to listen for Phone Calls

Didn't knew that Smiley Happy. Thanks for the explanation.

______________________________________________________
BB10-OAuth: GitHub
Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: How do you use callUpdated to listen for Phone Calls

Thanks for advise.  I tried everything...compiles and runs but never get any signals.  Has anyone been able to get signals when a call is incoming?  Thanks.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Contributor
Posts: 17
Registered: ‎09-05-2012
My Device: 9780 Bold
My Carrier: Bouygues Telecom

Re: How do you use callUpdated to listen for Phone Calls

[ Edited ]

To get the callUpdated signal, i do as following:

in main

 

qmlRegisterType<bb::system::phone::phone;("bb.system.phone", 1, 0, "Phone");
 

 

 

In my xml page:

import bb.system.phone 1.0

....

onCreationCompleted: {
phone.callUpdated.connect(CPPClass.onCallUpdated);
}

 

 

on your CPPClass.hpp

 

public slots:

void onCallUpdated(const bb::system::phone::Call &call);
 

 

And, my function onCallUpdated is invoked when i call someone or someone call me. But, i cannot do anything programatically to modify the call.

 

Goodluck

 

 

Developer
Posts: 1,621
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How do you use callUpdated to listen for Phone Calls

I have added the parts and now getting this stupid error msg during compile.

 

error: no matching function for call to 'TestApp::connect(bb::system:Smiley Tonguehone&, const char [39], TestApp* const, const char [41])'

 

 

HPP

 

public Q_SLOTS:

void onCallUpdated(const bb::system::phone::Call &call);

 

C++

 

    bool success = connect(phone,
                        SIGNAL(callUpdated(bb::system::phone::Call&)),
                        this,
                        SLOT(onCallUpdated(bb::system::phone::Call&)));

 

void TestApp::onCallUpdated(const bb::system::phone::Call &call)
{
}

 

I basically copied the code from the docs.

 

What is wrong with the code?  thanks

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How do you use callUpdated to listen for Phone Calls

[ Edited ]

TestApp should inherit from QObject or from one of it's subclasses.

 

Q_OBJECT macro should be present in the header.

 

#include <QObject>

class TestApp : public QObject { Q_OBJECT

After making these changes clean all & rebuild (so MOC is rerunned).

 

 

BTW, how phone variable is declared? You should pass a pointer to connect. Try:

connect(&phone, ...

Andrey Fidrya, @zmeyc on twitter