Android WebView 中的 WebSocket [英] WebSocket in Android WebView

查看:40
本文介绍了Android WebView 中的 WebSocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我的问题是我正在开发一个使用 WebSocket 的应用程序.在 iOS 上一切正常,但在 android 上,WebView 不支持 WebSocket.解决这个问题的最快/最优雅的方法是什么?

today my problem is that I am developing an app that is using a WebSocket. On iOS everything is working out fine but on android the WebView doesn't support the WebSocket. Whats the fastest/most elegant way to solve this problem?

由于这篇文章经常被查看,我想分享一些可能的解决方案.

As this post is viewed quite often I want to share some possible solutions.

解决方案:

  1. Java Websocket 客户端实现 &JavaScript 接口
  2. PHP Websocket 客户端实现&向 PHP 脚本发出背景(即 jQuery GET)请求(对我有用,因为我只想发送一行消息.)

Android Websocket 库

  1. http://autobahn.ws/
  2. http://code.google.com/p/weberknecht

有人遇到了同样的问题并描述了他的工作方式

  1. http://chpeck.tumblr.com/post/37273036645/socket-io-with-android-webview

推荐答案

Android webview 不支持 WebSocket.所以你需要用一些WebSocket库来实现.

Android webview doesn't accommodate WebSocket. So you need to implement with some WebSocket library.

jWebSockethttp://jwebsocket.org/

weberknechthttp://code.google.com/p/weberknecht/

weberknecht http://code.google.com/p/weberknecht/

这篇关于Android WebView 中的 WebSocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆