saveWebArchive() not working an Android 4.0.3
-
26-05-2021 - |
문제
I am trying to write a very simple code to save a web page to disk in a web archive in Android 4.0.3 ICS. My code is:
final WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.setWebViewClient(new myWebClient());
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("https://academics.vit.ac.in/student/stud_login.asp");
Button forward = (Button) findViewById(R.id.bForward);
Button back = (Button) findViewById(R.id.bBack);
Button update = (Button) findViewById(R.id.bUpdate);
forward.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (myWebView.canGoForward())
myWebView.goForward();
}
});
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (myWebView.canGoBack())
myWebView.goBack();
}
});
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myWebView.saveWebArchive("theArch");
}
});
The thing is, the webview is working perfectly but whenever I am clicking the Update button, what I get is (from LogCat):
03-26 18:41:38.797: D/webcoreglue(755): saveWebArchive: Failed to initialize xml writer.
and nothing else happens whatsoever.....
Please can anyone help me out on this; as this is a component of something else very important....
Thanks in advance!!!!
해결책
Try providing a fully qualified path, not "theArch"
. Use getFilesDir()
and the File
constructor to provide a path to internal storage, for example.
제휴하지 않습니다 StackOverflow