cWebView.setDownloadListener(new DownloadListener() {
@SuppressLint("DefaultLocale")
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
MimeTypeMap mtm = MimeTypeMap.getSingleton();
DownloadManager downloadManager = (DownloadManager) mCtx.getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.
String fileName = downloadUri.getLastPathSegment();
int pos = 0;
if ((pos = contentDisposition.toLowerCase().lastIndexOf("filename=")) >= 0) {
fileName = contentDisposition.substring(pos + 9);
pos = fileName.lastIndexOf(";");
if (pos > 0) {
fileName = fileName.substring(0, pos - 1);
}
}
웹뷰로 웹페이지의 파일다운로드받는부분인데
인터넷으로 코드를 얻었는데
int pos = 0;
if ((pos = contentDisposition.toLowerCase().lastIndexOf("filename=")) >= 0) {
fileName = contentDisposition.substring(pos + 9);
pos = fileName.lastIndexOf(";");
if (pos > 0) {
fileName = fileName.substring(0, pos - 1);
}
}
파일이름구하는데 위의 코드가 왜 필요한지를 모르겠습니다
contentDisposition
변수가 어떤의미인지도 잘모르겠구요
조언좀 부탁드립니다