How to send message to another android mobile using socket programming? - java

I am using API 10 and trying to develop an app for sending text and Multimedia messages to another android mobile using socket programming. What should I do for to fetch the IP address of mobile?

Lets explore the concept first..
Here we go :
What should I do for to fetch the IP address of mobile?
Which IP address...? Which keeps changing over the fraction of time and which does not hold any static ip...? You must read and study..
Network Systems
Operating Systems
Data structures
Database Systems
Software Developmental Life Cycles and Paradigms
Information Systems
Procedure oriented Languages
OOPS languages
Then you must have analytical and reasoning abilities of how things must be developed and how it can be implemented along with above knowledge.
Every device on internet may be mobile phone or a computer holds dynamic ip address.
I am using API 10 ..??
This does not matters what you use..!!
Trying to develop an app for sending text and Multimedia messages to another android mobile using socket programming.
socket programming..!! Please Do some basics of socket programming implement some sample codes first.
I have done it all... :(
Then its time to get all books back on the table to clear the concepts again as we do know nothing.. Or very poor a reasoning skills..!!
How Stuff Works :
Lets take example of any major social media like whatsapp and not only whatsapp but it is the very basic concept which every developer can tell you or follow to develop what you said..
Program your app to communicate with your web-server via sockets
Every App user must register to create account on server.
If any user sends message save it into his accounts sentbox on server
Check if recipient has a account on this web-server?
If yes then copy that message into his accounts inbox
Make app to fetch data via sockets if there is a change in his account on web-server
These are basics which can be extended to the IsSent and IsReceived by some tricks
Tricks..? Fetch user data via app on which screen user is? and send it to server.
The same data can be shared to show IsSent and IsReceived ..!!
In Short :
Every app performs socket programming and communicates to the fix server. which has fix static Ip address or a web server. As a end user who does not know programming and basics of software engineering :
Keeps both phones near to each other and asks another ... I have sent a whatsapp message to your phone.., Look does it received...? Not received yet...???!!! Get the both phones close to each - other .., so that it will get sent and received soon... Oooh... See .... I said .. Keep phones closer to receive messages faster..!! :)

Related

A connection between 2 applications

I would like to manage a connection between 2 applications, they will run on diffrent phones.
The purpose doesn't really matters let's say that it would be some kind of a chat.
How can I create this connection between the applications? I know how to do it on pc java programs using the socket and the serverSocket classes but I guess it's diffrent in here since the phone might change his ip when he moves between networks.
So how would you do that? how would you create a connection between 2 applications/phones
Given the scenario you described in your comment, using Push Notification i.e Google Cloud Messaging (GCM) might be sufficient.
So, when program B wants update from program A, it will ask the server to push a notification (via GCM) to program A. Note that program A will not connect to the server every x time to check for updates.
Another out-of-the-box solution is to use SMS if the communication is not so frequent and messages are short. Here I mean SMS that will be processed directly by your app (given it has certain attention word) and will not go to the inbox i.e. no SMS notification on the phone
Since the two phones will, as you note, have changing IP addresses, you'll probably need to use an intermediary.
The general design pattern here would be to have a server with a fixed IP or DNS address that relays messages between your two mobile devices. The simplest implementation would be a webserver, to which each phone would connect via HTTP(S) to transmit data or poll for updates.
There are a number of backend-as-a-service platforms that provide this type of functionality pre-built, and would likely suffice for something like a chat system. Check out Cloudmine and Parse.
If you need a low-latency or near-realtime connection, you could also consider implementing your own server that uses the Android C2DM (Cloud to Device Messaging) service.
See Android's Sample Bluetooth Chat App, It will give you an idea for how it can be achieved.

How do we manage SMS and which is the best language to approach?

I know that many has been ask for how to create a SMS server, but there has been been a fragmentation of knowledge because some just ask for a C# or PHP solution. My situation is different:
I need to develop 2 different services:
Receive SMS with a key work of what kind of information the client's client wants, like "FOOTBALL SCHEDULE" and the search in some data-base to send back to the sender's phone something like "12/12 NY X LA at 14:00h \n 13/12 DC X TX at 21:00h";
Client comes to my site and pays for 1000 SMS with message "Merry Christmas to you Girls!" with the possibility to enter the numbers or pick a random set in our own database according to what kind of people he/she wants to inform.
For that I can use:
Delphi or Java for Desktop/Web or Java for Android or PHP for Web;
MySQL or Firebird
A personal server or a Internet 3rd party server;
A SMS API service on the Internet or a personal phone with unlimited SMS sending pack.
So, the options are many. I can use a Android App in a Cell Phone or other kind of App in my PC connected to the Phone via USB. I can also use the Nokia NetBook that comes with a 3G slot and manage it from my App.
I have never made a program to handle any cell phone network services.
What I'd like to know from the unlimited StackOverflow users wisdom is:
Which of these options are the best to practice in the matter of available resources for SMS in these technologies?
Is there any finished community project with these arguments that I can be part of or import any piece of code/knowledge to mine?
Is there an API with these two services already available?
I am trying to avoid to contract a cellphone network provider to do that services. The cost would made it impossible. We are not intend to get a great profit, just to make these kind of services available in my region.
Thank You All!
there are plenty of web to sms gateways available worldwide.
usually they offer a http interface for incoming and outgoing sms.
so the simplest solution would be to find an affordable gateway provider and setup any kind of webserver to listen to the http request from the gateway provider on incoming messages.
this could be done in any environment you're familiar with.
for outgoing messages you would simply call an url of the gateway provider like
http://examplegateway.com/send?msisdn=23443&message=Merry+Christmas+to+you+Girls&secret=somesecrethash
this is easier than to program on the phone directly and usually cheeper, too. at least here in europe.
the contracts to the gateway providers come in as many differenty flavors as there are providers out there. with prepaid, postpaid, bulk-prices, monthly fee, pay-as-you-go you name it.
1 ) IMHO, and for my experience, the option 4 is the best, because this option allows you to have better scalability, and you separate the SMS logic, from you inner logic. Also, you don't need a person for maintain any server.
In the future, maybe you need to create another service, or another app. Using the option 4, you can reuse some code (or only the SMS API). Now you're using Android, but in the future, maybe you wanna create a Java Desktop Client, or iOS, or windows mobile, or.....
2 ) IDK :(...
3 ) IDK 2. I'm from Argentina, and we use a service only available here (Intertron)

how to send messages within LAN using MAC address

I had a query related to java programming. I have two wifi modules connected to my access point and my android phone connected to the same access point. Can I send a string message to any of the two modules from my phone using only MAC address? I dont want to create a server on my phone.
Any help is much appreciate
"Can I send a string message to any of the two modules from my phone
using only MAC address?"
Theoretically: Yes, but hard work.
You would need to implement a transport-layer protocol just for that. What speaks against using the IP stack? It has some more overhead in comparison to just sending the messages based on Ethernet but that overhead is totally okay in comparison to the effort you had to invest in building the your own protocol-stack.
"I dont want to create a server on my phone."
You don't need to create a server on your phone. The other two modules do need a "server" that is listening for the message from your phone. Your phone would need to run a client capable sending the message to the other two modules.
Please don't misunderstand me here, but from the question you are asking I'd say working on such a project with that little knowledge would be very frustrating.
If you want to pull it off I recommend having a look at Jpcap. It is a Java library that is design to capture and send network packets.
You can't do any I/O in Java based on a MAC address unless you are prepared to use third party stuff.

Is it possible to transfer data directly between two android devices to other users in the same network?

Let's say I have two android mobile devices, connected to the same wireless network, and that network hasnt external/internet access.
Without third party software, is it possible to transfer data through wifi without knowing the ip from each other and without creating an hotspot? Something like we do on Windows (if 2 pcs are on same network, they can share information directly without internet access)
Starting with the basics, I would like to develop an application, where android phones on same network appears on a list , and then a user choose on of them and writes something - and if the other user have the same app running, appears that on his phone (and then he can reply of course - basically, a chat.
I know this make no practical sense, but believe makes all the sense for what I need to do (it's not a chat of course). If anyone knows anything, please help me - i found nothing.
Thanks in advance.
If you want to send data or messages from one phone to another using the network you will eventually need the IP address of the recipient phone. However, If you don't care about targeting specific phones you could always send UDP broadcast packets that each device on the network should receive.
If you don't want to manually specify an IP you'll need to create a discovery protocol that a phone uses to discover all the other phones on the network. You could do this buy scanning all available IP addresses and checking to see if they are a valid android phone. Or you could have each phone broadcast its presence on the network using a UDP broadcast packet sent to a predefined port.
Once you have discovered all the phones on the network its really up to you to decide how you want to send the data between phones and there are hundreds of examples of how to send data between devices/computers/processes using sockets.

Connect from java mobile application to webservice to read messages

I have a website where users can send personal messages between them, now I want them to recieve the messages also on their mobile phone but without having to send them a SMS.
I am thinking about providing them with a mobile phone with internet access over GPRS or 3G, then develop a Java application that will connect to the website and retrieve the messages.
On the website I am thinking to make a webservice where the phone will login, get new messages, and also be able to answer back to messages.
Does anyone know any mobile application tutorial that will do that? Or do you recommend me where to start? I never done a java mobile application before, I only work with websites and PHP.
I also tried to use ICQ, the client is already done for java and for iphone, and I've also found a script that will send ICQ messages from PHP, but ICQ server bans you for 20 minutes when you do many reconnections, so I have to develop some kind of ICQ bot always online that will check for new messages to send from the mySQL database and then send them, one per 2-3 seconds, so the server won't ban me for flooding.
Well any advice or recommendation is welcome about how to have users connected to the website messaging system from their phones.
Thank you!
Instead of a Java Application, I would do a mobile HTML web page for the mobile devices because it will be simpler to deploy. I know Java is supposed to be WRITE ONCE RUN ANYWHERE, but with JavaME is not that simple. You will have to create special deployments for different phones, and there are phones that do not support JavaME (iPhone) at all.
With a mobile WEB SITE, the only thing your mobile phone needs is a browser. Pretty much every feature/smart phone have a browser these days.
If you insist on developing a JavaME application, you are on the right track. You can publish some WebServices on your WebSite and consume them from JavaME. Here is a tutorial on how to do that.

Categories

Resources