Is it possible to use WebSockets or similar with a native Android application?
Asked Answered
B

4

10

I have a Node.js app that uses HTTP / REST (using Express.js), and a native Android application that communicates with this. This works fine.

I am now looking at writing a more real-time version, which can push messages to a native client. Unfortunately, it needs to be a native client, as there is some fairly complex work done with the data that simply will not be possible in a mobile browser for the forseable future (otherwise I would just wait for WebSockets support to appear in the Android browser).

So, my question is what are my options?

I know about the Android Cloud to Device Messaging framework, but this requires registration and a Google sign-in, and I would much prefer the server to be client agnostic.

Is there a reliable WebSocket client that I can use (ideally) to talk to a Node.js server running Socket.io? Or any other native method (using the NIO classes)?

Brickey answered 4/5, 2011 at 23:31 Comment(1)
Doesn't a native android app have tcp support? Just talk to node over a net socket.Capful
B
5

See Java socket.io client

Benue answered 5/5, 2011 at 0:24 Comment(0)
X
5

you could use https://github.com/koush/android-websockets. It is also mentioned in the socket.io wiki pages

PS: i know it is a bit late to respond to this post, but this for other like me who didn't find an answer to question like this.

Xenocrates answered 23/11, 2012 at 7:55 Comment(0)
H
0
compile node.js on Android natively
    implement jni wrapper of node.js
    ...

refer this link

https://github.com/paddybyers/anode/issues/15

Harper answered 20/8, 2013 at 5:13 Comment(0)
L
0

Let you try newest (2024) library for android and async operations android async

Leontina answered 2/6 at 11:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.