Use WebView analog login on Cnblogs's Android client, which will require the user's username and password to be uploaded to the WebView and then submitted, which tests all the normal mx3 Flyme3 and flyme4. However, on my htcG12 (MIUI4), and Samsung Note2 on the error.
The error code is:
The code is as follows |
Copy Code |
Public void Loginbypassword (string username, string password) { mcurrentrt = Enumrequesttype.loginfinish; final String strjs = String.Format ("javascript: document.getElementById (' Tbusername '). Value= '%s ';d Ocument.getelementbyid (' Tbpassword '). value= '%s '; document.getElementById (' Form1 '). Submit (); ", username, password); Mweb.post (New Runnable () { public void Run () { Mweb.loadurl (STRJS); } }); } |
Mweb.loadurl (STRJS), The Times is wrong, the content of the error is "android.view.windowmanager$badtokenexception:unable to add window--token null isn't For an application ".
The workaround is to set the MWeb settings without saving the password "Settings.setsavepassword (false);" The code is as follows:
code is as follows |
copy code |
@SuppressLint ( {"Setjavascriptenabled"}) private void Initialweb () { websettings settings = Mweb.getsettings (); Settings.setsavepassword (FALSE); Settings.setsaveformdata (false); settings.setjavascriptenabled (true); Settings.setblocknetworkimage (true); Mweb.addjavascriptinterface (New Jsinterface (), "ifobj"); mweb.setwebviewclient (mblogwebclient); } |
For this reason, but not all of the errors of "Unable to add window--token null isn't for a application".