0
votes

Is there any way to handle file activation in Windows Phone 8.1 Silverlight Apps? I want users to choose my aplication when certain type file is selected. I can, at least, add file type association to manifest file using the manifest xml code because it is not available at the manifest designer.

<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>

On the other hand, OnFileActivated method is not recognized.

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
}

According to msdn this mechanism works both Windows Store apps and Windows Phone Store apps. I wonder if it is possible in Windows Phone 8.1 Silverlight Apps.

1

1 Answers

2
votes

For Windows Phone Silverlight apps you'll register the file association in the WMAppManifest.xml. The basic registration is essentially the same, but the launching is slightly different since Silverlight apps and Runtime apps activate differently.

The Silverlight app will launch with a deep link URI containing a FileTypeAssociation tag and a filetoken which can be opened via a SharedStorageAccessManager.

There is sample code in the Windows Phone Silverlight development documentation: Auto-launching apps using file and URI associations for Windows Phone 8