Answer the question
In order to leave comments, you need to log in
How does Android 4.4 WebView work on downloading a file when an .xls is generated by the server?
Good afternoon . I hope for your help)))) I made an application like my browser, in android 4.0-4.3 downloading a file works when generating .xls by the server, in 4.4 downloading a dynamic link does not work.
public class MainActivity extends AppCompatActivity {
private WebView mWebView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.getSettings().setJavaScriptEnabled(true);
// set download page
mWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength)
{
Log.d( "3" ,"3");
}
});
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.loadUrl(" ya.ru ");
}
@Override
public void onBackPressed() {
if(mWebView.canGoBack()) {
mWebView.goBack();
} else {
super.onBackPressed();
}
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading (WebView view, WebResourceRequest request)
{
Log.i( "1" ,"1");
String url = view.getUrl();
view.loadUrl(url);
return true;
}
@Override
public void onLoadResource(WebView view, String url) {
Log.d( "5" ,"5");
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i("2", "2");
Contexttt = view.getContext();
Log.i("2", tt.toString());
view.loadUrl(url);
return true;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question