开发者

The onLoadResource function sporadically generates not found errors

开发者 https://www.devze.com 2023-03-30 10:41 出处:网络
I have a webview application that uses hooks to execute native java code (ie populate a local db) and to catch these hooks I use the onLoadResource function.

I have a webview application that uses hooks to execute native java code (ie populate a local db) and to catch these hooks I use the onLoadResource function.

It works as expected, but about 10% of the time I get server log errors of the hook being fired and its clogging up my logs with "not found" errors.

So it basically works like this:

  1. User loads their webview app
  2. In the app they click on of the hooks (http://domain.com/hook/datatopass)
  3. The onLoadResource does its processing and forwards the user to another page 开发者_StackOverflow社区(http://domain.com/home)

The majority of the time it works, but sporadically I get the "ERROR [http://domain.com/hook/datatopass] not found" error.

From what I can tell the user doesn't see any error pages, they get forwarded to the correct place - but I don't know why the onLoadResource doesn't catch every request before it logs an error. Anyone know how to avoid these errors being thrown, and why this is happening?


It seems for me that a Timeout occurs - sometimes.
Have you tried to set the timeout time higher ?

Or have you tried to show an ProgressDialog like below to locate the problem?

 public void onLoadResource(WebView view, String url) {
            // Check to see if there is a progress dialog
            if (progressDialog == null) {
                // If no progress dialog, make one and set message
                progressDialog = new ProgressDialog(activity);
                progressDialog.setMessage("Loading please wait...");
                progressDialog.show();

                // Hide the webview while loading
                webview.setEnabled(false);
            }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号