问题
I'm sharing some text with a link to facebook from apps on Windows Phone 8.1 and Windows 8.1. I want to have different text for social media (which I want to be "My App's link #MyApp") and email and text (which I want to be "My little bit of text").
In Windows phone the following code works:
DataRequest request = GetMyDataRequest();
// for social media
request.Data.SetRtf("My App's link #MyApp");
// for email and text
request.Data.SetText("My little bit of text");
However when it comes to windows 8.1, both email and social media use the request.Data.SetText() function - so I'm seeing "My little bit of text" for email and social media, when I want social media to be different text.
So my question is, how do I get windows 8.1 to behave like windows phone when I share some text. Or possibly how do I determine what kind of share (email, text, social media) I want to do and set the relevant text (I'm not sure this is possible though). Or maybe the question is when and why is SetRtf/SetText used, and is it possible to override this?
Thanks
回答1:
The assumption behind the share contract is that the source app (yours) has one piece of content to share but that the content may have different representations or means of accessing it. For instance, you might share a chunk of text as plain text, as RTF, or even HTML, with the latter two formats offering the opportunity to spiff up its formatting. Similarly, you might share an image as a bitmap, as a file, or as a URI to a cloud resource.
On the other side of the sharing operation, each target app may only understand or deal with some subset of the formats that you've provided and will pluck those formats off of the DataPackage as it sees fit. Which formats a given app handles (and in what order of preference) is entirely determined by that app's developer so you can't really make assumptions about a class of apps like "social media".
来源:https://stackoverflow.com/questions/25141730/share-text-to-facebook-from-windows-8-1-and-windows-phone-8-1