12-20-2012 04:06 AM
Hi,
As someone asks me an Invokation sample, I share my code ![]()
bar-descriptor.xml :
====================
<your prefix> : com.domain.application.openhandler
<qnx>
<!-- Invokation framework -->
<invoke-target id="<your prefix>.openhandler">
<type>APPLICATION</type>
<filter>
<action>bb.action.OPEN</action>
<mime-type>*</mime-type>
<property var="uris" value="file://"/>
</filter>
</invoke-target>
</qnx>
In this sample, my application can be called to OPEN any (mime-type = *) local (uris = file://) file in a new windows (APPLICATION)
Of course, you can change the filter, declare several invoke target.
And your C++ code :
===================
In your main class constructor :
MyApp:MyApp(Application &app,
QTranslator &translator, QString ¤tLocale) {
// Invocation framework init
initInvokationReceiving();
}
void MyApp::initInvokationReceiving(void) {
InvokeManager *iManager = new InvokeManager(this);
QObject::connect(iManager,
SIGNAL(invoked(const bb::system::InvokeRequest&)),
this,
SLOT(onHandleInvoke(const bb::system::InvokeRequest&)));
switch (iManager->startupMode()) {
case ApplicationStartupMode::LaunchApplication:
// Launched from homescreen
break;
case ApplicationStartupMode::InvokeApplication:
case ApplicationStartupMode::InvokeViewer:
case ApplicationStartupMode::InvokeCard:
// Invocation. Anticipate a call to handleInvoke() slot
break;
default:
break;
}
}
void MyApp::onHandleInvoke(const InvokeRequest& request) {
// If the client is also a target
// QString source = request.source();
// If it is a bound invocation
QString target = request.target();
// The action to be performed
QString action = request.action();
// Content type of the data
QString mime = request.mimeType();
// Location of data – out of band
QString uri = request.uri().toString();
// In-band data
QString data = QString(request.data());
// qDebug() << "source: " << source;
qDebug() << "target: " << target;
qDebug() << "action: " << action;
qDebug() << "mime: " << mime;
qDebug() << "uri: " << uri;
qDebug() << "data: " << data;
}
initInvokationReceiving permits to change your init behavior in function your startup mode. Sample, if your start-up mode is "Card", you don't create an application menu.
At last, in init, I register my callback SLOT to read the params sent by the application caller.
In onHandleInvoke, I read all params.
When your app is called from an other app, OS10 call your main constructor, then the onHandleInvoke will be called.
Nicolas
01-08-2013 06:55 AM
connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));
// Initialize properties with default values
switch (m_invokeManager->startupMode()) {
case ApplicationStartupMode::LaunchApplication:
m_startupMode = tr("Launch");
break;
case ApplicationStartupMode::InvokeApplication:
m_startupMode = tr("Invoke");
break;
case ApplicationStartupMode::InvokeCard:
m_startupMode = tr("Card");
break;
}
What is the difference between using the handleInvoke and onHandleInvoke?
01-08-2013 11:29 AM
01-24-2013 09:07 PM
Hi , I want find a way to invoke a settting screen as a card. Can I do this in qml . Please give me some advise. Thanks a lot.
01-25-2013 04:56 AM
This article helped me alot on that....
https://appbus.wordpress.com/2012/11/08/invoke-car
02-01-2013 12:01 PM
Details on invoking settings is here: https://developer.blackberry.com/cascades/document