简体   繁体   English

Android文件Webview下载

[英]Android file Webview Download

I am a novice and just to avoid running into difficulties, I created an app with a simple webview function that displays an external site, so that when I have to make a change, I go to the site and update the app as well. 我是一个新手,为了避免遇到麻烦,我创建了一个具有简单Webview功能的应用程序,该应用程序显示一个外部站点,因此当我必须进行更改时,我也可以去该站点并更新该应用程序。

The problem is that if I attach a file on the site (even a simple pdf) from the app it is not possible to download it despite having put the download permissions. 问题是,如果我从应用程序将文件附加到站点上(甚至是简单的pdf),尽管已设置了下载权限,也无法下载该文件。 Is there a way to "enable" all downloads from the app related to a site domain? 有没有办法“启用”与站点域相关的应用程序中的所有下载?

  <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> 

It seems that you gave the correct permissions in your Manifest, so the issue must be in the Java code. 看来您在清单中给了正确的权限,所以问题必须出在Java代码中。 Since you didn't attach it: you should have a webView.setDownloadListener() method. 由于您没有附加它:您应该有一个webView.setDownloadListener()方法。 This question is really similar to yours and might be helpful: 这个问题与您的问题非常相似,可能会有所帮助:

Download file inside WebView 在WebView中下载文件

Please attach Java code for a more specific answer. 请附加Java代码以获得更具体的答案。

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

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