从Windows Phone 8的共享 [英] Sharing from Windows Phone 8

查看:144
本文介绍了从Windows Phone 8的共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个的Windows Phone 8 应用,我试图分享通过DataTransferManager内容。 Windows的API文档说,它支持Windows手机,但是当 DataTransferManager.GetForCurrentView()函数被调用我得到一个异常

I am working on a Windows Phone 8 app and am trying to share content through the DataTransferManager. The Windows API documentation says it is supported in Windows Phone but when the DataTransferManager.GetForCurrentView() function is called I get an exception

System.NotSupportedException was unhandled by user code
  HResult=-2146233067
  Message=Specified method is not supported.
  Source=Windows
  InnerException: 

我一直在寻找的答案并不能找到任何人具有相同的问题,任何帮助将是AP preciated。关于这一主题的所有样品似乎是Windows 8的具体的,但电话8确实包含这些功能。下面是从我的应用程序示例code。

I have been searching for an answer and can't find anyone else with the same issue, any help would be appreciated. All samples on this topic seem to be Windows 8 specific, but Phone 8 does include these functions. Here's sample code from my app.

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
        dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(dataTransferManager_DataRequested);
    }

    private void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
    {
        DataPackage requestData = e.Request.Data;
        requestData.Properties.Title = "Share Text Example";
        requestData.Properties.Description = "An example of how to share text.";
        requestData.SetText("Hello World!");
    }

    private void Button_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
    {
        DataTransferManager.ShowShareUI();
    }

再次当上了 DataTransferManager.GetForCurrentView()页面加载异常被显示; 功能,因此它不会对其他线路,但包括他们无论如何。我试着添加/删除权限和组件,但必须缺少的东西。我也试过把功能不同的事件(如和Ontap功能)具有相同的结果。

Again, the exception is shown when the page loads on the DataTransferManager.GetForCurrentView(); function so it doesn't get to the other lines, but included them anyway. I've tried adding/removing permissions and assemblies but must be missing something. I've also tried putting the function in different events (such as the onTap function) with the same results.

如果有人有兴趣尝试这种对自己这里是一些文档:

<一个href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.applicationmodel.datatransfer.datatransfermanager.aspx\">DataTransferManager

<一个href=\"http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.datatransfer.datatransfermanager.datarequested.aspx\">DataRequested

<一个href=\"http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.datatransfer.datapackage\">DataPackage

<一个href=\"http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.datatransfer.datatransfermanager.getforcurrentview\">GetForCurrentView()

更新

虽然它可能不是对这个问题的背景下,最好的解决办法,我实现电子邮件/短信/链接任务如下所述,而不是使用DataTransferManager。似乎在WP8 DataTransferManager可能无法访问并且尽管任务将采取若干不同的功能,他们似乎是执行预定的功能的最佳方式。

Although it may not be the best solution given the context of this question, I am implementing the Email/Sms/Link Tasks as described below rather than using the DataTransferManager. It seems that DataTransferManager may not be accessible in WP8 and although the tasks will take a number of different functions they seem to be the best way to perform the intended functionality.

推荐答案

我想我已经找到大部分东西我一直在寻找与发射器......而不是仅仅使用Windows 8普通共享功能我可以用特定的任务/发射器。

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.

下面是我会实现的功能

    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();
    }

编号:

<一个href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769550%28v=vs.105%29.aspx\">Launchers对于Windows Phone的

<一个href=\"http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394009%28v=vs.105%29.aspx\">Share链接任务

这篇关于从Windows Phone 8的共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆