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
Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10
My Carrier: RIM

sharing data of type QString using Invocation Framework.

[ Edited ]

Hi all,

I want to share QString data using Invocation. Following is what the snippet  should be for using Invocation concept: 

 

Button{

text: "Share"

onClicked: {
invoke.trigger("bb.action.SHARE")
}
attachedObjects: [
Invocation {
id: invoke
query: InvokeQuery {
mimeType: "text/txt"
uri: "Hello World"
invokeActionId: "bb.action.SHARE"
}
}
]

}

 

I don't get any error as this Invocation Framework is not function now in beta3 of BB10, but the property we have to provide is uri over here. i.e. QUrl. Isn;t there any other way apart from providing filepath for sharing??

 

Thanks in advance.

Please use plain text.
Administrator
MSohm
Posts: 14,421
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: sharing data of type QString using Invocation Framework.

You should be using the data parameter of invocation instead of the uri parameter. https://developer.blackberry.com/cascades/reference/bb__cascades__invokequery.html#data

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10
My Carrier: RIM

Re: sharing data of type QString using Invocation Framework.

[ Edited ]

Hi, 

Seeing https://developer.blackberry.com/cascades/reference/bb__cascades__invocation.html I had tried data property as well. The documentation and the given example snippet guided me to use data property. Folliwing is what I had tried in my QML file.

 

Invocation {
id: invoke
query: InvokeQuery {
mimeType: "text/txt"
data: "Hello World"
invokeActionId: "bb.action.SHARE"
}

}

 


In this case, I get QML parsing Error stating: "Type mismatch of value of the 'data' property. Expecting QByteArray and found string"

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: sharing data of type QString using Invocation Framework.

try data: ["MyString"]

 

then it's an Array ;-)

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10
My Carrier: RIM

Re: sharing data of type QString using Invocation Framework.

Hi,

I tried data: ["mystring"]  and following is the screen when I trigger the invocation. I think this isn't what I should be getting.

 

IMAG0073.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Instead I should be getting the one providing four ways of sharing i.e. BBM, BBM Group, Bluetooth and Tag. Previously I was achieving it when I was trying with uri: "file:///share.txt". I'm attaching its screenshot as well.

IMAG0074.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

What I need is data..and not uri ! that's clear...but something is still going wrong, I'll be very thankful if you could help out.

Please use plain text.
Developer
igosoft
Posts: 71
Registered: ‎09-19-2012
My Device: Z10 very soon
My Carrier: Play

Re: sharing data of type QString using Invocation Framework.

 

Hi

 

Try the following

 

in C++

QByteArray MyClass::getByteArray(QString str)
{
return str.toAscii();
}

 

and set the context for QML

 

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

qml->setContextProperty("app", this);  /// this must point to MyClass

 

 

in QML

data: app.getByteArray("your_string")

Please use plain text.
Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10
My Carrier: RIM

Re: sharing data of type QString using Invocation Framework.

Hi,
I converted my string to ByteArray in QML itself. So ideally it should work now. but still I'm not getting options for sharing (as shown in screenshot2 above.)
Please use plain text.
New Contributor
farahh
Posts: 4
Registered: ‎03-14-2011
My Device: BB 10
My Carrier: None

Re: sharing data of type QString using Invocation Framework.

I was having same error as you are. Take a look at this sample: https://github.com/blackberry/Cascades-Community-Samples/tree/master/InvokeClient and see how they implemented app.invokeQuery() and app.processQueryReply()

You need to create your own list of matching applications that can allow you to share this text. After you have this code ready: use IN QML:
Invocation {
id: invoke
query: InvokeQuery {
mimeType: "text/txt"
data: "I am staying at Hilton"
}

However, I do not see BBM or BBM Group in the list. How can I get BBM and BBMGroup in the list?
Please use plain text.
New Contributor
farahhanif
Posts: 7
Registered: ‎01-07-2011
My Device: Not Specified

Re: sharing data of type QString using Invocation Framework.

mimeType: "text/plain" shows the BBM option

Please use plain text.
Trusted Contributor
georg22
Posts: 245
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: sharing data of type QString using Invocation Framework.

I would like to share a few lines of text including line breaks ("\n"). Is it possible?

Please use plain text.