Skip to content
a little java implementation of missing WebSocket form Android webview
Branch: master
Clone or download
FreakDev Merge pull request #2 from IndrekV/master
Calling loadUrl to execute javascipt closes softkeyboard
Latest commit 8667af1 Nov 5, 2012
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
java-src/com
js Workaround for javascript execution. Calling loadUrl on a view trigge… Nov 5, 2012
README.md first commit Oct 31, 2010

README.md

Android HTML5 WebSocket

A Java library that make the WebSocket object available for project that uses a WebView (like PhoneGap project's)

The iOS version of the plugin was already existant (http://github.com/remy/PhoneGap-Plugin-WebSocket) and works well for me, but the Adnroid version was missing. here it is.

Usage

  • copy the Java source into the source folder of your project.
  • copy websocket.js in your assets/www folder
  • copy / paste these two line inside the onCreate of your activity
   WebSocketFactory wsFactory = new WebSocketFactory(appView);
   appView.addJavascriptInterface(wsFactory, "WebSocketFactory");
  • in your javascript, create a new WebSocket, and overload its method 'onmessage', 'onopen', 'onerror', 'onclick';
You can’t perform that action at this time.