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

Posts: 102
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Close app after invocation

[ Edited ]



my App reads in a file binary. I'm having a problem when opening a corrupt file from the filebrowser or an email-attachment. Because in this case I want to app to close again.

Here's the code:

In the applicationUI constructor I connect the signal (when I open a file from e.g. the filebrowser) with a slot.


ok = QObject::connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));


void ApplicationUI::handleInvoke(const bb::system::InvokeRequest& request) {

// Initiate the appropriate target based on the invoke.target-key
	if (request.target() == "com.myApp.card.previewer") {
		// card should init as the specified target

		m_uri = request.uri().toString();

		QString FileToOpen = m_uri.replace(QString("file://"), QString(""));

// read the content of the file binary. If an error occures result is set to "false". When the complete file is read correctly result is set to "true" bool result = ApplicationUI::readDataFromFile(FileToOpen); if (result == false) { ShowToast("An error occured while reading the file"); Application::quit(); } else if (result == true) { ***open the file*** } else { ShowToast("An unknown error occured"); } } else { ShowToast("ERROR! Card not found!"); } }

 But when I open an corrupt file the Toast Message "An error occured while reading the file" isn't shown.

Instead the screen gets darker two times and then I get the error message "Unable to open *filename*".


Can anyone tell me how after an invocation the app can be closed?