简体   繁体   English

如何使用intent://在Android Chrome和Angular中打开PDF(6)

[英]How to use intent:// to open a PDF in Android Chrome and Angular (6)

I have a page that lists PDFs and everything works fine until you try and open one in Chrome on Android. 我有一个列出PDF的页面,在您尝试在Android上的Chrome中打开一个PDF之前,一切正常。 I have searched and found references to using 'intent://' but have not been able to figure it out. 我已经搜索并找到了有关使用'intent://'的引用,但无法弄清楚。

In my component I have the following intent path that I append to the URL 在我的组件中,我将以下意图路径附加到URL

  intentPath = '#Intent;scheme=http;action=android.intent.action.VIEW;end';

And the link itself is built in the component with: 链接本身是通过以下方式在组件中构建的:

  androidOpenPDF(url) {
    let newURL = url.replace('http', 'intent') + this.intentPath;
    window.open(newURL, "_blank");
  }

The HTMl is: HTMl是:

<a class="btn" target="_blank" (click)="androidOpenPDF(pdfURL)">VIEW PDF</a>

I had a similar problem the below code worked for me : 我有一个类似的问题,下面的代码为我工作:

public void openPdf() {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.someurl.com/some-pdf"));
        startActivity(browserIntent);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM