【问题标题】:How to handle file activation in Windows Phone 8.1 Silverlight Apps如何在 Windows Phone 8.1 Silverlight 应用程序中处理文件激活
【发布时间】:2015-08-17 19:26:36
【问题描述】:

有没有办法在 Windows Phone 8.1 Silverlight 应用程序中处理文件激活?我希望用户在选择某种类型的文件时选择我的应用程序。我至少可以使用清单 xml 代码将文件类型关联添加到清单文件,因为它在清单设计器中不可用。

<Extension Category="windows.fileTypeAssociation">
   <FileTypeAssociation Name="alsdk">
      <DisplayName>SDK Sample File Type</DisplayName>
      <Logo>images\logo.png</Logo>
      <InfoTip>SDK Sample tip </InfoTip>
      <EditFlags OpenIsSafe="true"/>
      <SupportedFileTypes>
         <FileType ContentType="image/jpeg">.alsdk</FileType>
      </SupportedFileTypes>
   </FileTypeAssociation>
</Extension>

另一方面,OnFileActivated 方法无法识别。

protected override void OnFileActivated(FileActivatedEventArgs args)
{
   // TODO: Handle file activation

   // The number of files received is args.Files.Size
   // The first file is args.Files[0].Name
}

根据msdn,此机制适用于 Windows 应用商店应用和 Windows Phone 应用商店应用。我想知道在 Windows Phone 8.1 Silverlight 应用程序中是否有可能。

【问题讨论】:

    标签: c# windows-phone-8.1


    【解决方案1】:

    对于 Windows Phone Silverlight 应用,您将在 WMAppManifest.xml 中注册文件关联。基本注册基本相同,但启动略有不同,因为 Silverlight 应用程序和运行时应用程序的激活方式不同。

    Silverlight 应用程序将启动 包含 FileTypeAssociation 标记和文件令牌的深层链接 URI,可通过 SharedStorageAccessManager 打开。

    Windows Phone Silverlight 开发文档中有示例代码:Auto-launching apps using file and URI associations for Windows Phone 8

    【讨论】:

    • 我尝试过并设法启动了我的应用程序,但我无法获取存储文件。 SharedStorageAccessManager 只有两种方法。第一个 GetSharedFileName 仅返回所选文件名(甚至不返回其路径)。第二个是将文件复制到所需位置的 CopySharedFileAsync。无论如何我可以从令牌中获取 StorageFile,例如 StorageApplicationPermissions.FutureAccessList.GetFileAsync(token);
    猜你喜欢
    • 2014-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多