我在WindowsPhone应用程序开发中很新颖。我目前正在为Windows Phone 8.0开发Unity应用程序。这里面的应用程序,我想用手机上的相应的应用程序打开一个PDF(Acrobat Reader软件时,Windows阅读器等)在Windows Phone 8.0的Unity应用程序中使用关联的应用程序打开PDF文件
首先,我想这一点:
void PDFButtonToggled(bool i_info)
{
Dispatcher.BeginInvoke(() =>
{
DefaultLaunch();
});
}
async void DefaultLaunch()
{
// Path to the file in the app package to launch
string PDFFilePath = @"Data/StreamingAssets/ImageTest.jpg";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(PDFFilePath);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
throw new Exception("File launch failed");
}
}
else
{
throw new Exception("Could not find file");
}
}
这回我一个例外,所以我搜查了为什么我发现这个话题(写在2013年:/)关于异步函数/线程:LINK。为了使sumarize,这里的团结工作人员的答案:
它只会在Windows应用商店应用程序,你必须在#if NET_FX /#endif包装代码。在其他平台上,您不能在脚本中使用async/.NET 4.5代码。如果你想将它用于windows phone,你必须在单独的visual studio解决方案中编写代码并将其编译为DLL,因此unity可以将其用作插件。
因此,我决定创建在Unity手册中描述的双DLL解决方案:LINK。但是当我用上面给出的“async void DefaultLaunch()”函数完成第一个DLL的类时,我没有关于Windows.ApplicationModel.etc和Windows.System.etc的引用。
而且我在这里,一点点WP,团结,8.0的应用程序,StoreApps等之间失去了...... 如果任何人有意见,问题,任何可以帮助我,这是值得欢迎的。 :)
克雷弗克