Sharing from Windows Phone 8

╄→尐↘猪︶ㄣ 提交于 2019-11-27 08:44:49

I think I have found most of what I was looking for with Launchers... Rather than just using the Windows 8 general sharing functionality I can be specific with Tasks/Launchers.

Unfortunately it doesn't have as many sharing options as the charm does, I will be implementing several functions for email/sms/social but so far this is the best solution.

Here are the functions that I will be implementing

    private void ShareLink(object sender, System.Windows.Input.GestureEventArgs e)
    {
        ShareLinkTask shareLinkTask = new ShareLinkTask()
            {
                Title = "Code Samples",
                LinkUri = new Uri("http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff431744(v=vs.92).aspx", UriKind.Absolute),
                Message = "Here are some great code samples for Windows Phone."
            };

        shareLinkTask.Show();
    }


    private void ShareEmail(object sender, System.Windows.Input.GestureEventArgs e)
    {
        EmailComposeTask emailComposeTask = new EmailComposeTask()
            {
                Subject = "message subject",
                Body = "message body",
                To = "recipient@example.com",
                Cc = "cc@example.com",
                Bcc = "bcc@example.com"
            };

        emailComposeTask.Show();
    }

    private void ShareSMS(object sender, System.Windows.Input.GestureEventArgs e)
    {
        SmsComposeTask smsComposeTask = new SmsComposeTask()
            {
                Body = "Try this new application. It's great!"
            };

        smsComposeTask.Show();
    }

Ref:

Launchers for Windows Phone

Share Link Task

kindasimple

According to my API reference, DataTransferManager is reserved for native apps only. Windows Phone API Quickstart.

Have you tried using the fully qualified method? It would be something like this:

DataTransferManager dataTransferManager = indows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();

Also, make sure your target is Windows Phone 8.

The Windows 8 Share Contract isn't supported on WP8. There isn't even a Share charm on WP8. Why are you trying to use the DataTransferManager?

Instead of using the Share Contract, most usecases can work just fine with WP8 app2app custom protocols and file extensions. Using WP8 app you can transfer files and data across apps. Althrough the standardized contract of the Share Contract is gone, apps can create their own contracts using custom protocols and file extensions.

Here for example you can learn more about a real-world 3rd party implementation of Nokia Music custom protocols.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!