我的Android应用程序中有一个webview.
我已经加载了网址:https://imsnsit.org/imsnsit/notifications.php
有各种通知的链接.单击它们时,我的WebView无效.它正致力于其他一切 - Chrome(Android),Chrome(桌面).链接很好.有一点我注意到通知有PHP文件的href.只是导航到该链接不起作用.我得到无效的操作.此外,链接不是静态的,每次刷新页面时它们都会更改(只有plum_url.php的参数).
我已经在使用这些功能了.什么都没有帮助.
webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDomStorageEnabled(true);
所以这里是场景:
当我从 Firebase 存储访问文件时:
当我从 Firebase 托管访问文件时:
我从最近的 Firebase CDN(.html、.png、.zip 等)获取我的文件(顺便说一句,小文件不超过 2mb)。
将该文件存储在我的本地存储中,以便应用程序不需要再次下载并消耗服务器的带宽。
每次应用需要时从本地存储使用它。
注意:我version.txt在存储桶(Firebase Storage)上也有一个文件。根据此文件中的值,我决定是否再次获取步骤 1 中的文件。这意味着version.txt每次都获取。
问题:
托管的优点: 会更快。关联
PS:
1. 我关心的是带宽而不是安全性。
所以这是场景:
我正在从网络下载 PDF 并将其保存在/0/Download/NSIT - Notices/"fileName".pdf
现在发送 Intent 像这样:
private void openPDF(String fileName) {
Log.d(TAG, "openPDF: called");
Intent intent = new Intent(Intent.ACTION_VIEW);File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download", "NSIT - Notices");
File myPDF = new File(Environment.getExternalStorageDirectory() + "/Download/NSIT - Notices", fileName + ".pdf");
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", myPDF);
Log.d(TAG, "openPDF: intent with uri: " + uri);
intent.setDataAndType(uri, "application/pdf");
context.startActivity(Intent.createChooser(intent, "Open with..."));
}
Run Code Online (Sandbox Code Playgroud)
现在任何 PDF 阅读器(Google Drive PDF 阅读器、系统 PDF 查看器)都在说
The File Does Not Exist
Run Code Online (Sandbox Code Playgroud)
谷歌没有做任何事情(这就是为什么不包括它的图像)
Mainfest.xml
<provider
android:name="android.support.v4.content.FileProvider" …Run Code Online (Sandbox Code Playgroud) pdf android android-intent android-fileprovider android-storage