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: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar
Accepted Solution

Trouble with BPS

I have a utility class that i'd like to use in my app. This utility class give me infor about device and son and in this utility class i include a method to return if the device has or not internet access.

I use the code in the BPS tutorial and take the StatusEventHandler class to my app. However i got problems when compiling in this line  :

 

signals:
void networkStatusUpdated(bool status, QString type);

 

It only said to me that it has a syntax error..

Also in the console I got :

 

o-g/.obj/moc_BlackBerry10Utils.o: In function `BlackBerry10Utils::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':
C:\Users\ybracho\ndk-10.1.0-workspace\ProfitMovil\x86/o-g/.moc/moc_BlackBerry10Utils.cpp:49: undefined reference to `BlackBerry10Utils::networkStatusUpdateHandler(bool, QString)'

 

Any hint for solve this problem ?

 

TIA,

 

 

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

Re: Trouble with BPS

[ Edited ]
 

Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Contributor
Posts: 12
Registered: ‎04-23-2013
My Device: Z30
My Carrier: Truphone

Re: Trouble with BPS

I would check the following:

* Check that the class has 'Q_OBJECT' at the top

* The error is in the moc file so do a clean to ensure qmake runs again

* If it's still unresolved then check that the symbol is correctly defined in a cpp file (remove 'inline')

* Check that it is a class member function, i.e.

void MyClass::networkStatusUpdated(bool status, QString type)
{

 

and not

void networkStatusUpdated(bool status, QString type){
{

 If you are connecting from a signal to a slot (I think you're going the other-way) ensure that networkStatusUpdated in the header file is in a protected/private slot section:

private slots:
   void networkStatusUpdated(bool status, QString type);

 I think you're providing a signal so make sure it's in the signal section.

 

 

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Trouble with BPS

[ Edited ]

Thanks.

It's working now but because it works asynchronously,i got the answwer after my screen appears...!!

Is there a way to wait for the answer before show the screen or continue with program execution ?

 

Thanks a lot

Retired
Posts: 47
Registered: ‎04-19-2013
My Device: I love them all!
My Carrier: Carriers rock!

Re: Trouble with BPS

If you're working with the BPS events in a Cascades application, I would highly recommend implementing bb::AbstractBpsEventHandler. It will tie the BPS event delivery in to the Qt event loop.
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Trouble with BPS

Thanks for the info. 

So I remove StatusEventHandler from my project and made BlackBerry10Utils inherit from AbstractBpsEventHandler.

However I got this message in my .hpp file 

 

../src/BlackBerry10Utils.hpp:25:52: error: expected class-name before ':' token
../src/BlackBerry10Utils.hpp:25:52: error: expected '{' before ':' token
../src/BlackBerry10Utils.hpp:25:52: error: expected unqualified-id before ':' token

And the line is the "class BlackBerry10Utils...."

 

#ifndef BLACKBERRY10UTILS_H_
#define BLACKBERRY10UTILS_H_

#include <QObject>
#include <QString>
#include <QVariant>

#include <bb/device/HardwareInfo>
#include <bb/platform/PlatformInfo>
#include <bb/ApplicationInfo>
#include <bb/system/phone/Phone>
#include <bb/AbstractBpsEventHandler>
#include <bps/bps.h>

class BlackBerry10Utils : public QObject, public bb:AbstractBpsEventHandler {
	Q_OBJECT
...

 It looks fine to me but the compiler tells me there is an error, can somebody help to discover it ?

 

TIA

Retired
Posts: 47
Registered: ‎04-19-2013
My Device: I love them all!
My Carrier: Carriers rock!

Re: Trouble with BPS

You're missing a second colon in the namespace for the AbstractBpsEventHandler.

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Trouble with BPS

Oh my god!!! Shame on me!!!
Thanks!!!
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: Trouble with BPS

Hi,

 

 When i inherit public bb::AbstractBpsEventHandler to applicationui.hpp file at that time i get below error into main.cpp file

 

     cannot declare variable 'appui' to be of abstract type 'ApplicationUI'

 

 So any one know how i need to resolved this issue?