Vũ Ngây Thơ Vũ Ngây Thơ - 7 months ago 37
Android Question

Can not download in Android webview

Possible Duplicate:

Download File inside WebView

I have a WebView on my screen:

webDownloadTicket = (WebView) findViewById(R.id.webViewToDownload);
webDownloadTicket.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
// and load url
// setup for download listener
webDownloadTicket.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);


I was testing with browser, going to this URL
and then press the download button, it will download a JSON file.

But when I test on my Android app with that code, it can load the web page but can not download anything when I press download button.

Answer Source

The most common answer for not being able to access network from an app is a missing permission-declaration in AndroidManifest.xml. Check the file for this line and add it if it's not there:

<uses-permission android:name="android.permission.INTERNET" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download