I need to program an Android application that integrates with a web-based system that has SSO (Single Sign On) authentication. The system will pop up a web page that prompts for the username and password, if the login is successful then it sets a (memory based) cookie with an encrypted session ID, then the popup window will "kill" itself with a javascript window.close() function call. All standard stuff really, I have written Excel VBA applications on Windows that work perfectly well with this system - the user wants to log in, the SSO server will pop up an IE window, the user provides their credentials and the window disappears, from then on integration from Excel to the remote system works because there is a session cookie created.
I tried to do the same with an Android app. I called the SSO login page with a WebView call, it displayed perfectly well and I logged in, expecting the login popup page to disappear and my Android application to continue. However, my problem is that in Android, a javascript call to windows.close() is effectively ignored, all it does is blank the screen and leave it showing. Thats fine, I dont care if the window still exists, as long as my cookie is created, and the user can easily navigate back to my app. So here is开发者_如何学编程 my question:
How can I pop up a URL, get the user to log in to the SSO, then easily get the user back to my application.
I have done a lot of reading and experimentation but have reached a brick wall.
Thanks,
Steve
May be you already know it, but by default, JavaScript is turned off in WebView widgets. If you want to enable JavaScript, call getSettings().setJavaScriptEnabled(true) on the WebView instance to enable javascript.
I've written twitter client and they use OAuth for authentication. After login they simply redirect browser to the page you provide and can register activity for this action.
In your case if they just close the window, may be previous activity from the stack will be shown.
加载中,请稍侯......
精彩评论