I need to send data from a java app to an android app in real time. The data is not large(integers within 0 and 9) but the number of transmissions is high, around 5 transmissions per second.
I wish to have a publisher subscriber model. Java app is going to push data to the android app instead of android app continuously pinging the java app for data.
Transmission has to be in real time and will happen over a LAN.
Tried with GCM but its not real time. Pubnub is another but not sure how realtime it will be.
How to proceed ?
PubNub is as real-time as it gets... and it's super easy to make a Java server talk to Android device (in fact, PubNub has client SDKs for over 50 different platforms!).
This same code will run on both Android and plain Java:
import com.pubnub.api.*;
import org.json.*;
Pubnub pubnub = new Pubnub("demo", "demo");
Callback callback = new Callback() {
public void successCallback(String channel, Object response) {
Log.d("PUBNUB",response.toString());
}
public void errorCallback(String channel, PubnubError error) {
Log.d("PUBNUB",error.toString());
}
};
try {
pubnub.subscribe("demo", callback);
} catch (PubnubException e) {
Log.d("PUBNUB",e.toString());
}
pubnub.publish("demo", "Hello World !!" , callback);
The complete walkthrough is available here:
http://www.pubnub.com/docs/java/javase/tutorial/data-push.html
If you have additional questions about it, feel free to contact [email protected], and they'll be happy to assist you further.
geremy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With