在Android上打开pdf文件并不起作用

时间:2016-08-19 07:38:22

标签: c# android pdf path unity5

我试过

public void OpenPDF(string filename)
{
    TextAsset pdfTemp = Resources.Load ("pdf/" + filename, typeof(TextAsset)) as TextAsset;
    System.IO.File.WriteAllBytes(Application.persistentDataPath + "/" + filename + ".pdf", pdfTemp.bytes);
    Application.OpenURL(Application.persistentDataPath + "/" + filename + ".pdf");
}

也做了

void OnClick(){
    string path;
             //set the correct path to the rules files
    if (Application.platform == RuntimePlatform.Android) {
        path = System.IO.Path.Combine(Application.streamingAssetsPath, Tag.rulesFilename);
        WWW www = new WWW(path);
        Application.OpenURL(www.url); //intent launches but nothing happens
    }
    else {
        path = System.IO.Path.Combine(Application.streamingAssetsPath, Tag.rulesFilename); 
        Application.OpenURL(path);
    }
}

已经做了

public void OpenPDF(string filename)
{
string path = System.IO.Path.Combine(Application.persistentDataPath, filename + ".pdf");

    TextAsset pdfTemp = Resources.Load(filename, typeof(TextAsset)) as TextAsset;

    File.WriteAllBytes(path, pdfTemp.bytes);

    Application.OpenURL(path);
}

我的pdf档案," voca.pdf"并没有出现过。 在Resources文件夹,Assets文件夹,StreamingAssets中尝试 这些代码来自http://answers.unity3d.com/ 但是Android上的Toast消息只说"无法打开文件"

你怎么能弄清楚这个? 如果完成,我会感激不尽。

0 个答案:

没有答案