With the new release of the developer tools being available, the guys from the Windows Phone team introduced two interesting classes that allow content sharing directly from a third-party application. These classes are:
ShareStatusTask allows the user (or developer, since he actually is able to invoke the task) to post a status to one of the services linked with the user account on the physical device. For example, this includes Facebook, Windows Live and later on possibly Twitter and LinkedIn.
Both ShareStatusTask and ShareLinkTask classes are processing the request for the same application:
As with the Marketplace and internal applications, the app URI scheme is not available externally (through WebBrowserTask or by typing the address in Internet Explorer). The URL above is called when the Show method is called for the task, and not surprisingly - the tasks are invoked the same way as any other standard task in NoDo:
ShareStatusTask task = new ShareStatusTask(); task.Status = "User Status"; task.Show();
Status is the only available property, so there is nothing overly complicated about using this class. One thing to remember, however, is the fact that whenever the Show method is called, the status won't be automatically set - to avoid misguided usage, the user will have to confirm the status provider and the status itself.
Both ShareStatusTask and ShareLinkTask inherit from ShareTaskBase, that is the link to the sharing application. What's even more interesting - it appears that at a later time developers will be able to do much more than simply share things but also perform check-ins (Facebook Places and/or Foursquare integration?):
ShareLinkTask is a bit different - it allows sharing web content to the same services that are registered on the device and that are compatible with the content being shared. Take a look at this snippet:
ShareLinkTask task = new ShareLinkTask(); task.LinkUri = new Uri("http://dennisdel.com"); task.Message = "Check out my blog"; task.Title = "Den by default"; task.Show();
For now there is no way to define the sharing provider through the class (although I just filled a Microsoft Connect ticket). Also, the sharing mechanism will not work in the emulator - you will need a physical device updated to the dev release of Mango to see the results.