Chat application using Socket programming android - android

Is it possible to do a chat between client and server (two android devices) using socket programming in android?If possible,anybody please offer me a help.Even a link is acceptable.

It is possible. you can use socket programming and create chat application with 2+ devices. one device must act as server and others have to be client. if your want to your server to be android device and don't want have web server side it does not need an internet connection. just a access point or one mobile hotsopt is enough. but all device must be connect to same hotspot or access point.

Related

How to create socket connection for chatting in android

I have to develop a chatting application and I want to use socket connection. is there a way in android for it. Which will be better way for long time application.
Give me suggestion about it.
Have you looked at the Sockets class? You can use sockets to write and read data between two clients in background threads that update the UI thread with the data received/sent.
Generally with sockets one device (the client) connects to another (the server) and it is expected that the server's hostname will not change. However, you can't guarantee this with devices on mobile networks so a better approach might be to have two devices connect to a well known server that relays chat messages through. If you're just trying to do a basic chat application between devices on the same LAN it would be fine to directly connect them however.
https://developer.android.com/reference/java/net/Socket.html

What are the alternatives to allow two Android devices to exchange message?

I'm planning to build an Android application.
In this app the users must be able to communicate each other when they are close (a priori fixed distance).
I think that the easiest way to implement this model is with a server-client architecture where every message goes from a client to the central server and then the server will forward the message to the target client.
CLIENT A ---M---> SERVER ---M---> CLIENT B
But this way the the system doesn't scale and, in a scenario with a lot of Clients, the Server will become the bottleneck.
I'd like to ask what are the alternatives (on Android) to allow two smartphones to communicate and exchange message in a bidirectional way when they are close to each other.
CLIENT A ---> CLIENT B CLIENT C ---> CLIENT D
CLIENT A <--- CLIENT B
For example, is it possible, assuming a distance small enough, a solution based on Bluetooth? Or it is possible open a TCP/UDP socket between the two devices?
You could use NFC (if the device has it) to pair the devices via Bluetooth or WiFi Direct. If you don't have NFC, simple Bluetooth pairing without it should still work, NFC just makes it convenient.
I have used this server solution, and it's pretty awesome: http://www.rabbitmq.com/
RabbitMQ is a messaging service with a pretty awesome interface for Android.
I can't speak as to how you would implement either bluetooth or TCP/UDP.

Developing a multiple client one server application Android

I want to develop an application that has socket connection with many clients or Android devices connected to one Android device as the server with TCP connection. The server receives information (name, IP address, device name) from the clients and saves it to the database.
Once the information was saved, the server will send a message to the clients and show the clients the list saved in the database (name, IP address, device name).
I'm new with socket programming and I want to implement KyroNet library that is working for Android too. Can anyone help me give a sample code to get started with this project?
I'm not familiar with the KyroNet library, but you should look at the BluetoothChat example application provided with Android. Bluetooth sockets are just about the same as a regular socket, so it should be nearly identical code-wise. The app also shows how to implement a Handler and Thread for the connections.

Android - Create RESTful WebService - Host it on mobile

My question is how to create a web service on android device & host it on the mobile device.
I don't want to access an already created webservice deployed on a server; I want to create a webservice that returns json/xml & host it on mobile.
RESTful Web Services Implementations in Mobile Devices says it's doable for Java-based mobile devices, so I think it can be done for Android too.
There is one problem with your setup and mobile devices: mobile networks (wifi and 3g) mostly use NAT, which prevents inbound connections. This makes mobile devices inaccessible from the internet (inbound) while they can still initiate outbound connections. For this reason mobile devices mostly do not host servers.
What you can do is make an Android service which pings a server ( a web-server) every 30 minutes or so simply send a bit from client to server and back to check the availability of request from another phone. This way you can upload media files to server and download them to your another device.
I am trying to solve the same problem and I am leaning towards https://github.com/NanoHttpd/nanohttpd.
It is a tiny webserver without any REST or MVC functionality, thus you would have to write it yourself (MVC, content negotiation, etc).

Need to use WLAN in android

I developed an app for android tablet, Now i need to perform certain actions on the app through my android phone using WLAN... How to do it?
Your app can create a server socket to receive client requests, and then interpret commands that your remote client sends to it. This page might help you with the Android server socket part of things.

Categories

Resources