android - How to redirect after a login in webview? -
i developing android application . used webview create ui , ajax connect server . there login.html file have 2 text inputs , sends username , password server , if server returns success redirects index.html file . unfortunately doesn't redirect index.html . in android emulator works in android 6 mobiles doesn't work . body knows how redirect in webview in situation ?
var username = $("#username").val(); var password = $("#password").val(); var params = { "username": username, "password": password }; $.getjson("http://warehouse-abforce.rhcloud.com/api/v1/login", params, function (data) { document.getelementbyid("wait").style.visibility = 'hidden'; if (data["success"] == "true") { window.localstorage.setitem("name_user", data["name"]); window.localstorage.setitem("username", $("#username").val()); window.localstorage.setitem("password", $("#password").val()); if (navigator.useragent.match(/android/i)) document.location = "index.html"; else window.location.replace("index.html"); });
finally found solution . should add code java code . wv webview object . shouldoverrideurlloading must implemented , returns false . works in both mobile , emulator of version 6 . redirects second page successuly .
wv.setwebviewclient(new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { return false; } });
Comments
Post a Comment