SimpleEvent will not work, since we need to return WebResourceResponse.
We need a procedure with a result.
Maybe we can add a property to indicate which procedure will be called if RequestInterception needed.
SimpleEvent will not work, since we need to return WebResourceResponse.
We need a procedure with a result.
Maybe we can add a property to indicate which procedure will be called if RequestInterception needed.
Response contains headers which are returned as a dictionary.
finally I add a property InterceptDict, and when shouldInterceptRequest method is called, it will look up in InterceptDict.
} else if (interceptDict.containsKey(request.getUrl().toString())) {
String newpath = interceptDict.get(request.getUrl().toString()).toString();
InputStream is = null;
String mimeType = null;
String encoding = null;
try {
if (newpath.toLowerCase().startsWith("http://") || newpath.toLowerCase().startsWith("https://")) {
is = new URL(newpath).openConnection().getInputStream();
mimeType = URLConnection.guessContentTypeFromStream(is);
encoding = "UTF-8";
} else {
String path = context.getExternalFilesDir(null).getPath() + "/" + newpath;
is = new FileInputStream(path);
mimeType = URLConnection.guessContentTypeFromStream(is);
encoding = "UTF-8";
}
} catch (Exception e) {
}
if (SdkLevel.getLevel() >= 21) {
HashMap headers = new HashMap();
headers.put("Access-Control-Allow-Origin", "*");
return new WebResourceResponse(mimeType, encoding, 200, "OK", headers, is);
}
return new WebResourceResponse(mimeType, encoding, is);
}
If you can, I would appreciate a PR. It will be useful indeed.
Sorry I still don't know how to PR.
Anyway, you are free to modify/add this code in your next release if you want.
How to ask for location permission?
How to handle SSL errors?
How to handle JS events?
I created a browser using the CostumWebView extension and I cant find a way to make multiple tabs possible, does anyone know how?
Hi,
i wonder why would i recieve 404 error when the web page is loaded otherwise?
and i dont get to see any message or id againsts it.. url is ok though
Error codes are returned for page contents too.
So it is possible that a resource failed to load.
how to check what exactly has failed?
url
should be of resource.
If not then you'll have to check logcat.
please help, I made a WEB form APP SCRIPT application which I will make a mobile version of, the problem is when I want to download an excel file using a plugin:
ajax/libs/xlsx/0.14.3/xlsx.full.min.js
which when I download it always fails because the url becomes:
blob: https://n
and I also made an MS Word export feature which also can't be downloaded because the error file reads:
data:application/vnd.ms-word;charset=utf-8
how do i make a download file for my web app using a custom webview?
web application links:
https://script.google.com/macros/s/AKfycbxlMub33-l6OjsW6JISw83RU-yGSMP2SMk3jTN-UOzorMRUJobZ8iT2DOZInA8Sq00/exec
login:
user:demo
pass: demos
download on the user menu and pengajian menu
thanks
You cannot download a blob url using the android webview.
everything runs normally when on the computer but the download always fails when using a custom webview
Is there another solution so I can make the download feature
the excel file download url changes to: blob:https://n-kwyw4ei5ng4wc2as6camw7nhscfabxrze522nhq-0lu-script.googleusercontent.com/d11c1730-8daf-4be5-ad6e-af7daf9bae98
while the word file changes to:
data:application/vnd.ms-word;charset=utf-8,%3Chtml%20xmlns%3Ao%3D'urn%3Aschemas-microsoft-com%3Aoffice%3Aoffice'%20xmlns%3Aw%3D'urn%3Aschemas-microsoft- com%3Aoffice%3Aword'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2FTR%2FREC-html40'%3E%3Chead%3E%3Cmeta%20charset%3D'utf-8'%3E%3Ctitle %3ESIAP%20~%20abu%20musa%20computer%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3E%3Cp%20style%3D%22text-align%3A%20center%3B%22%3E%3Cstrong% 3REGISTER%20BOOK%20YELLOW%20WHICH%20TEACHED%3Cbr%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20AND%20TO%20REFERRAL%20SCIENCE% 3Cbr%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20PONDOK%20BOARDING SCHOOL%20CONTOH%3Cbr%3E%0A%20%20%20% 20%20%20%20%20%20%20%20%20%20%20YEARS%20STUDY%202022%2F2023%3C%2Fstrong%3E%3C%2Fp%3E%20%3Ctable%20border%3D%221% 22%20style%3D%22border-collapse%3A%20collapse%3B%22%3E%3Ctbody%3E%3Ctr%3E%3Ctd%20style%3D%22width%3A%2045px%3B%20text-
Where are your excel and word files? If you store them on google drive then download is straightforward, or for that matter any suitable online server location.
I don't save excel or word files, both I created directly using the javascript plugin:
Then consider saving them to files on google drive first, then download those files.