Fix a summary of WebView controls under Android

Source: Internet
Author: User

In the game there is a collection of player problem feedback pages, a long time ago colleagues have said that Android in the game can not upload attachments, in the browser is normal use. Recently can make a shot, on a careful look at the problem, found that there are a lot of problems, here a record down, hoping to be useful to others, because a lot of problems with the online reflection may be a bit different.

Since it is a Web page and only appears in the game, the first step is to use Fiddler to intercept the request and locate the problematic code. You can refer to this article, grab the bag has already been described in very detailed, step by step Fiddler (iv) realize the mobile phone clutch

Find the requested page link in fiddler, click to view the text of the response to use the Text tool (I am using the EditPlus) to save, and then modify it, and then use the Fiddler autoresponder for request interception, you can be dynamically debugged

However, after you open the HTTPS request in the Fiddler, you will be prompted to use Chrome to access the HTTPS link when the site is not authenticated, the phone installation certificate, my device must set a gesture password, after the settings can not cancel the gesture must first remove the certificate to restore the previous no-gesture access.

Problem one: Some Android devices cannot enter letters, numbers, but can input Chinese, return button click Invalid (webpage does not back)

Many online, including Stackflow will have a lot of results, I tried a lot, no one can solve the problems I encountered, and some people say is a bug, finally I was in an article suddenly found that I am currently using the code to write a problem (leaving staff left), this article link here:

Use of WebView in Android development (full program included)

Old code, where the red label is directly returned to true, change to Super.onkeydown (KeyCode, event) is normal.

Question two: Android devices click on the page of the Input[file] control is invalid

I found the solution through this article: Android WebView uploading files

Search out the answer, I can't remember that URL, is on the StackOverflow, but it's the parameter is a bit problematic, the above three functions as if there is a function of the parameters it is written "Valuecallback" no back <uri> This is actually problematic, unified for valuecallback<uri> uploadmsg, just the question of the length of the argument behind it

Issue three: Upload attachments may experience a failure, the upload succeeds when calling History.go (-1) does not work

A Select question Type page A, a Question detail form page B. There are many incoming URLs when called by WebView's Loadurl method. For example: The role of the current game, Server Ah, game product identification, device Mac, such as a long string of information, click on the form page B, and more with a type.

In page b, the user clicks a hyperlink to a element (href= "Javascript:history.go (-1);") It can return normally, but after clicking the Submit Question button, the Ajax interface succeeds with JS call History.go (-1) page into blank, incredibly blank!!!

Online Search a lot of methods, but also tried a lot, the results have failed, try several scenarios:

SmartPhone Web Development Issues Summary

Android:detect History.back () in WebView

Why is Javascript:history.go (-1); Not working on mobile devices?

WebView back without redirects

First eliminate the problem set in Java because JavaScript is working, proving Mwebview.getsettings (). Setjavascriptenabled (True);

Then I try to modify the code directly locally, and calling History.go (-1) when the page loads is complete works. Originally I tried to use location.href = Document.referrer, the results found not to get referrer, about Document.referrer can refer to this article >>

And then I just want to not create the form form dynamically, then get the parameter list through DOCUMENT.LOCATION.SEARCH.SUBSTR (1), then fill in input with all the parameters and then submit the form on the page to jump? But also write some code, so I want to find out if there is no other way ...

I then carefully review the HTTP upload request, try to delay the call History.go (-1) in the success method of Ajax.ajaxfileupload, and find that the interface is misaligned. At this time I suddenly will not submit the form when it dynamically created an IFRAME causing the call History.go (-1) failed?

File Upload ajaxfileupload plugin uses content-disposition to implement, More about content-disposition You can parameter this article: correct handling of HTTP header encoding issues when downloading files (content-disposition)

I did not read the source code carefully, and then I changed a way: History.go (1-history.length), the page will return to normal.

Picture upload failure problem, need to be linked with the background, more time-consuming, is not bound to encounter. Also more trouble, so temporarily on hold, the feeling is caused by coding problems, pending further confirmation ...

Hope that the above three problems can give people who encounter similar problems some help, through the search to deal with the completely unknown problem, it really needs to be careful and patient, especially in time tense situation, must not be impatient, a manic thought may be disorderly

Fix a summary of WebView controls under Android

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.