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: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

terminate the BB 10 app on Alert button ok pressed

I have a socket connection App in my BB 10 cascades, when ever socket connection is closed i need to show a dialog box and when pressed on OK button app need to close.

please find my code here...

void SocketBase::writeLine(QTcpSocket *socket, const QString &line)
{
if (socket->state() != QAbstractSocket::ConnectedState)
{
       onOkAlert("Please check your internet connection and restart the app again");
}
}

 

void SocketBase::onOkAlert(const QString &message) {

dialog = new SystemDialog(tr("OK"), 0); 
dialog->setTitle(tr("Alert")); 
dialog->setBody(message); 

 bool success=      QObject::connect(dialog,SIGNAL(finished(bb::system::SystemUiResult::Type)),
                        this,
                SLOT(onDialogFinishe(bb::system::SystemUiResult::Type)));
 if(success){
 dialog->show();
}

 

class SocketBase: public QObject{
     Q_OBJECT
    public:
SocketBase(const QString &ipAddr, const ushort port) :
        mIP(ipAddr), mPort(port) {
    mRunThread = false;
}
enum Identity {
    BAD_IDENTITY, SERVER, CLIENT
};
virtual void startThread() = 0;
virtual void stopThread() = 0;
virtual Identity getIdentity() = 0;
 Q_INVOKABLE void showDialog(int id);
 void onOkAlert(const QString &message);

 private slots:
     void onAPPFinished();
     void onDialogFinishe(bb::system::SystemUiResult::Type);
     }

 

void SocketBase::onDialogFinishe(bb::system::SystemUiResult::Type)
{
qDebug()<<" dialog->result():::"<<dialog->result();
    if(dialog->result()==2)
    {
        qDebug()<<"::: Terminate App :::";
        bb::Application::exit(0);
    }

}

 and I also added at top of my class,

using namespace bb::data;
using namespace bb::cascades;
using namespace bb::system;
SystemDialog *dialog;

 dialog box is displayed but when ok button pressed onDialogFinishe() is not called 

what is wrong in my code, please help!!!

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: terminate the BB 10 app on Alert button ok pressed

You're missing a d on OnDialogFinished or is that just a copy typo?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: terminate the BB 10 app on Alert button ok pressed

[ Edited ]

Okay you've actually spelled it that way fair enough, have you checked your are getting a valid connection by Q_ASSERTing the connection?

 

[Edit] Woh I'm on fire today 2 for 2, you have! :-)


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: terminate the BB 10 app on Alert button ok pressed

I am getting ture here 

bool success=      QObject::connect(dialog,SIGNAL(finished(bb::system::SystemUiResult::Type)),
                        this,
                SLOT(onDialogFinishe(bb::system::SystemUiResult::Type)));

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: terminate the BB 10 app on Alert button ok pressed

Yes, sorry brain elsewhere (playing GTA V).

 

Try putting;

 

dialog->setDismissAutomatically(true); // Hides the dialog when a button is pressed.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: terminate the BB 10 app on Alert button ok pressed

yeah, I did it but app doesn't terminate 

Highlighted
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: terminate the BB 10 app on Alert button ok pressed

You could try bb::Application::instance()->requestExit()
Like all of my posts