I'm working with this feature where user can share an image to social media such as Facebook and Twitter. The image is the screenshot of some screen. and when the screenshot is taken, i checked on the gallery and the image is located to "Device/photos/image1.jpeg".
And now i want to share that image to social media. here's my code :
void invoke(QString target){
InvokeManager invokeManager;
InvokeRequest request;
request.setAction("bb.action.SHARE");
// target == "Facebook" or "Twitter"
request.setTarget(target);
// request.setMimeType("text/plain");
request.setMimeType("image/jpeg");
// request.setUri(QUrl("Device/photos/image1.jpeg"));
request.setUri(QUrl::fromLocalFile("Device/photos/image1.jpeg"));
InvokeTargetReply *targetReply = invokeManager.invoke(request);
invokeManager.setParent(this);
if (targetReply == NULL) {
qDebug() << "InvokeTargetReply is NULL: targetReply = " ;
} else {
qDebug() << "reply != NULL ";
// qDebug() << "targetReply : " << targetReply->setParent(this);
qDebug() << "request action : " << request.action();
qDebug() << "request target : " << request.target();
qDebug() << "request uri : " << request.uri();
qDebug() << "request mime : " << request.mimeType();
targetReply->setParent(this);
}
}
When this function is called, nothing happened. and i see on the console, it printed "reply != NULL" which means that invokeTargetReply has reply my request. but nothing happened.
I try to change the mimeType to "text/Plain" so it's just sharing a plain text to Facebook. And it works fine. I'm guessing that the mistakes is with the URI of the file. I'm not sure how is the correct way to setUri. can anyone help me ? a smallest help would be very appreciated.
Thanks Regards,
Yoga