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
Highlighted
Developer
Posts: 102
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none
Accepted Solution

Problem with open file in App via InvokeRequest

Hi,

 

my App opens files and reads its content binary. I have a little problem when opening a file from a filebrowser or an email attachment.

But first here is how my app works. I have a signal/slot-connection in my applicationUI constructor:

ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app), m_invokeManager(new bb::system::InvokeManager(this)) {

  bool ok;

  // Since the variable is not used in the app, this is added to avoid a
  // compiler warning.
  Q_UNUSED(ok);
 
  ok = QObject::connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));

}

So if a file is clicked it will can opened in the following C++-function:

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

	QString workingDir = QDir::currentPath();

// Initiate the appropriate target based on the invoke.target-key
	if (request.target() == "com.myapp.card.previewer") {

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

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

		bb::cascades::Page* PageToOpen = ApplicationUI::doLoadPageDetails(FileToOpen);

		if (PageToOpen != NULL) {
			initPreviewerUI();
		} else {
			ShowToast("FEHLER! Seite kann nicht geladen werden");
		}
	}
}

 The doLoadPageDetails()-function creates a page and fills it with content read binary from a file. If the file contains has errors or is corrupt an exception is thrown.

 

And here is my problem. When I open a corrupt file first the screen gets darker before the app opens. The I get the error messages exactly as I want. But the the screen stays darker. I can't pick another item from the filebrowser. Also I can't use the back-button. The only solution is to wipe the screen and then use the active frame to close the filebrowser and then reopen it.

This I can't use with email attachments. When I open on and the screen gets darkened I can't close the view to the mails. So to see the mails again I have to restart the BB decive.

 

I'm not fluid in english but I hope you can understand my problem. Is there a way to cancel the invokeRequest when the file is corrupt? Or what can I do here?

 

 

Developer
Posts: 145
Registered: ‎12-23-2012
My Device: BB10 Dev Alpha
My Carrier: wifi

Re: Problem with open file in App via InvokeRequest

May be you should varify the data before you open previewUI, atlest some basic sanity checks.

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

Re: Problem with open file in App via InvokeRequest

But I do that. When an error occurs in the doLoadPageDetails-function it returns "null". Which means the PreviewerUI isn't initiated.

But there's the problem. When the PreviewerUI isn't intiated the screen stays shaded. And I can't picl another item or close the filebrowser, if I opened the file from a filebrowser.

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

Re: Problem with open file in App via InvokeRequest

Okay, the solution was not to use a Toast message but Dialog box. Because this stops the application and I can and shows just the message, then I can with the button on this Dialog tell the app to close again.