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: 12
Registered: ‎03-09-2011
My Device: Z10
My Carrier: T-mobile

Howto share HTML file. Should be simple but does not work.

Hi,

There are aa lot of questions regarding this already in the forum and tons of hints but still no success. Here is the code:

 

void SBF::shareFile(){

	QString path = QDir::current().absoluteFilePath("shared/documents/privacy.html");
	path.prepend("file://");
	qDebug() << "Share: " << path;
	m_pInvocation = Invocation::create(InvokeQuery::create().parent(this).uri(QUrl::fromLocalFile(path)).mimeType("text/html"));
	QObject::connect(m_pInvocation, SIGNAL(armed()), this, SLOT(onArmed()));
	QObject::connect(m_pInvocation, SIGNAL(finished()), m_pInvocation,SLOT(deleteLater()));
}

void SBF::onArmed(){
	qDebug()<< "onArmed";
	m_pInvocation->trigger("bb.action.SHARE");
}

 When I call shareFile I get the folowing in the log window:

Oct 29 13:01:22.458    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.129253627    default    9000    NOTICE      InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="text/html"
   uri=QUrl("file:file:///accounts/1000/appdata/com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6/shared/documents/privacy.html") 
   data= "" 
   metadata= QMap() 
   perimeter= 0 
   action= "" 
   target= "" 
   invokerIncluded= false

 There seems to be a file: too much. So I changed the path.prepend("file://") to path.prepend("//") and got the following:

Oct 29 12:59:52.988    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.128819448    default    9000    NOTICE      Invocation failed for action="bb.action.SHARE", target="sys.invokeTargetSelection", reason="Internal"

 

I already tried to add mimeType text/html. Any idea.

 

Michael

The famous Movie Quiz:
http://appworld.blackberry.com/webstore/content/34285892/?lang=en&countrycode=DE
Highlighted
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Howto share HTML file. Should be simple but does not work.

I've noticed this sample app published in the Community github repo:

 

https://github.com/blackberry/Cascades-Community-Samples/tree/master/ShareFile

 

It leverages the File picker however.  Does that help?

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Developer
Posts: 1,065
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Howto share HTML file. Should be simple but does not work.

InvokeQuery was broken by BB10.2. That error message you are seeing is exactly the symptom we've all been seeing. Even if you are doing it right it won't work. You have to use InvokeManager with an InvokeRequest instead.

 

I recently packaged the whole solution up in a neat little C++ class that can be used from QML too. A couple of lines of code and you can do any kind of invocation you like, plus it works on ALL BB10 versions, including 10.2.

 

 


MichaelBuc wrote:

Hi,

There are aa lot of questions regarding this already in the forum and tons of hints but still no success. Here is the code:

 

void SBF::shareFile(){

	QString path = QDir::current().absoluteFilePath("shared/documents/privacy.html");
	path.prepend("file://");
	qDebug() << "Share: " << path;
	m_pInvocation = Invocation::create(InvokeQuery::create().parent(this).uri(QUrl::fromLocalFile(path)).mimeType("text/html"));
	QObject::connect(m_pInvocation, SIGNAL(armed()), this, SLOT(onArmed()));
	QObject::connect(m_pInvocation, SIGNAL(finished()), m_pInvocation,SLOT(deleteLater()));
}

void SBF::onArmed(){
	qDebug()<< "onArmed";
	m_pInvocation->trigger("bb.action.SHARE");
}

 When I call shareFile I get the folowing in the log window:

Oct 29 13:01:22.458    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.129253627    default    9000    NOTICE      InvocationWrapper::onQueryFinished: no matching result from Menu Service for query
   mimeType="text/html"
   uri=QUrl("file:file:///accounts/1000/appdata/com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6/shared/documents/privacy.html") 
   data= "" 
   metadata= QMap() 
   perimeter= 0 
   action= "" 
   target= "" 
   invokerIncluded= false

 There seems to be a file: too much. So I changed the path.prepend("file://") to path.prepend("//") and got the following:

Oct 29 12:59:52.988    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.128819448    default    9000    NOTICE      Invocation failed for action="bb.action.SHARE", target="sys.invokeTargetSelection", reason="Internal"

 

I already tried to add mimeType text/html. Any idea.

 

Michael






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
New Developer
Posts: 12
Registered: ‎03-09-2011
My Device: Z10
My Carrier: T-mobile

Re: Howto share HTML file. Should be simple but does not work.

Hi,

Thanks for the hints. I know the example but even the example does not work in my setup:

Oct 30 12:07:05.921    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.35905755    default    9000    NOTICE      InvocationWrapper::onInvokeFinished: invocation failed with error 2 
Oct 30 12:07:05.921    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.35905755    default    9000    NOTICE      Invocation failed for action="bb.action.SHARE", target="sys.invokeTargetSelection", reason="BadRequest"
Oct 30 12:07:05.921    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.35905755    default    9000    NOTICE      InvocationWrapper::onInvokeFinished: action = "bb.action.SHARE" , target = "sys.invokeTargetSelection" 

 Might have something to do with 10.2 on my device? I will have a look at your class. See you,

 

Michael

The famous Movie Quiz:
http://appworld.blackberry.com/webstore/content/34285892/?lang=en&countrycode=DE
Developer
Posts: 1,065
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Howto share HTML file. Should be simple but does not work.

[ Edited ]

Yes, you are using InvokeQuery, which DOES NOT WORK ON BB10.2! Even if you don't use my class you will still need to change over to using InvokeManager and InvokeRequest instead of InvokeQuery.

 

Note that InvokeActionItem uses InvokeQuery internally, so it is broken too on 10.2. BlackBerry has acknowledged this problem and plans a fix in a future 10.2.x release, but for now many, many apps that worked fine with 10.0 and 10.1 now can no longer do invocations since 10.2.0.474 was pushed out around the world. If you switch over now to the InvokeManager/InvokeRequest method your app will work properly with ALL versions of BB10.


MichaelBuc wrote:

Hi,

Thanks for the hints. I know the example but even the example does not work in my setup:

Oct 30 12:07:05.921    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.35905755    default    9000    NOTICE      InvocationWrapper::onInvokeFinished: invocation failed with error 2 
Oct 30 12:07:05.921    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.35905755    default    9000    NOTICE      Invocation failed for action="bb.action.SHARE", target="sys.invokeTargetSelection", reason="BadRequest"
Oct 30 12:07:05.921    com.michaelbu.SBF.testDev_chaelbu_SBF88cbcaf6.35905755    default    9000    NOTICE      InvocationWrapper::onInvokeFinished: action = "bb.action.SHARE" , target = "sys.invokeTargetSelection" 

 Might have something to do with 10.2 on my device? I will have a look at your class. See you,

 

Michael






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.