I need Communication for my android applications to send and receive some messages without using internet and server. I think I should use something like ad-hoc or bluetooth but I have no idea which is better and where to start. can anyone show me a way to start?
Related
I need some help in terms of choosing a design option for my problem.
I currently managed to implement a RaspberryPi acting as a Server and my local machine to act as the client. This client send JSON-Data to the Server which processes these. Everything is working as expected and I am using TCP-Sockets for the communication.
My problem:
The next step of my project will be, that I will use instead of a PC an Android-Device as client. What I want to achieve is, to send data to the server on the go. What I mean by that is, I do not want to restrict the server to be in a special network neither the client. What can be expected, is that server and client are next to each other, like in the range of a bluetooth connection. My question is, is there a relatively simple way to implement this communication? Is TCP a possible solution for this (even working in mobile networks?) or do I need to use Bluetooth, or is the way to go, to create some kind of network the client/server connects to and communicate here?
Sorry for propably stupid questions, but I am new to all this network stuff.
EDIT:
Since there were no respones, maybe I can do a more precise question. Is there a proper way to scan a network for a device name?
The only way I currently can imagine is to do a bruteforce like check on every IP-Address and resolve the names?
I first tried to let the Pi host an ad-hoc network, but it seems that non-rooted android smartphones do not have the possibility to access ad-hoc networks.
Therefore I made the Pi acting as an access point.
The communication now is very simple realized by a tcp server-client system.
I am looking to create a simple app that will help me better understand sockets and how they work inside of Android. My idea is to try and create a simple messaging app that will allow users to connect to the host phone and then send messages.
I am hoping that once a message is sent all phones connected to the host will be able to see the messages and reply.
My question is that as I am very new to Android, is there any material out there or tutorials that will guide me into getting this up and running or something similar? Has anyone else tried something like this before and are sockets the best approach to be using?
I test WiFiDirectDemo that is available as Android example, it works as it should. Now this app work as Server-Client. What I want is to work as p2p. Both devices should be able to receive and send data.
I don't know how to achieve communication in both ways?
Any direction in the right way would be much appreciated.
It seems that both devices serves as client and server. And sending messages between is simple, Developer should just implement system for checking and acknowledgment.
I am looking for the feasibility of implementing an ad-hoc type messaging service on Android. Basically I want a several Android users to be able to communicate (text is enough at this point) without having a cellular connection. But there can be a centralized access point. For example a low-power computer with a wireless router.
What is the best way to implement something like this? I was thinking using XMPP. Could use the computer as the XMPP server and let Android users connect to it. Is this a reasonable approach?
Any suggestions are greatly welcomed.
Thank you.
Adhoc and XMPP fit together in this context as follows: the network connections between the phones are adhoc; XMPP defines client to client server-less messaging. Two issues need be solved:
1) The adhoc Android connections - not clear to me if this is generally possible
2) Finding an XMPP Android client library that supports the xep-0174 protocols. The Smack library supports this, and I think it currently runs in Android.
Since you are using a centralized access point, it is straight forward, you open a socket connection between the different devices and exchange the data you need. I am not sure why you call it ad hoc though.
I am doing a project where I have too develop an application that listens for incoming events by a service. The device that has to listen too events is an Android phone with Android SDK 1.5 on it. Currently the services that call events only implement communication trough UDP or TCP sockets. I can solve my problem by setting up a ServerSocket, but i doubt that's the most power efficient way. This application will be running most of the time, with Wi-Fi on, and I'd like too reach an long battery duration. I've been looking for options on the internet for my question for a while but i couldn't get a real answer. I've got the following questions:
What is the most efficient way too listen to incoming events? Should I make an ServerSocket? or what are my options?
Are there any other implementations that are more power efficient?
Ive been also thinking of implementing communication trough XMPP. Not sure if this is the best way. I'm not forced too an specific implementation. All suggestions are welcome!
Thanks for the help,
Antek
You already listed the possible choices. If the app has to be able to handle events, it also needs to be running all the time. afaik there is no push-notification-service that automatically calls your application, like on the iPhone.
I think using a protocol like XMPP is the most easy solution. Having your own ServerSocket would also mean the server has to send requests to different IPs whenever you are switching your network.