How to make webview to download in android
I used ourSite variable to webview
Use following code for download file from webview
ourSite.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent downloadit = new Intent(Intent.ACTION_VIEW);
downloadit.setData(Uri.parse(url));
startActivity(downloadit);
}
});
Import header file
// for downloadlistener
import android.webkit.DownloadListener;
//for webview
import android.webkit.WebView;
I used ourSite variable to webview
Use following code for download file from webview
ourSite.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent downloadit = new Intent(Intent.ACTION_VIEW);
downloadit.setData(Uri.parse(url));
startActivity(downloadit);
}
});
Import header file
// for downloadlistener
import android.webkit.DownloadListener;
//for webview
import android.webkit.WebView;
I appreciate your post. Thanks for posting.
ReplyDeletesap training institute in Noida
sap training institute in Delhi