You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/12/24 12:32:38 UTC
[GitHub] zcl0001 opened a new issue #1960: Android websocket 官网提供的adapter send方法 小米手机出现:android.os.NetworkOnMainThreadException
zcl0001 opened a new issue #1960: Android websocket 官网提供的adapter send方法 小米手机出现:android.os.NetworkOnMainThreadException
URL: https://github.com/apache/incubator-weex/issues/1960
建议修改官网,目前项目如下修改,加了个线程:
`@Override
public void send(final String data) {
if (ws != null) {
ThreadManager.getNormalPool().execute(new Runnable() {
@Override
public void run() {
try {
Buffer buffer = new Buffer().writeUtf8(data);
ws.sendMessage(WebSocket.PayloadType.TEXT, buffer.buffer());
buffer.flush();
buffer.close();
} catch (Exception e) {
e.printStackTrace();
reportError(e.getMessage());
}
}
});
} else {
reportError("WebSocket is not ready");
}
}`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services