Get Binary Data from external device on Android Phone - android

I'm looking for some input on how to go about a problem I have. We have a device that has binary data that it needs to send out (they are mainly just symbols, but in a custom binary format) over ethernet. I need to intercept this data on the phone and display the symbols over google maps. I'm just wondering the best way to go about this, I have a few ideas but am not sure if they are possible or feasable:
Is it possible for the phone to connect directly to the device if the device had some sort of server running on it, then poll for new data? If so, what is the protocol needed to be able to direct connect like that?
Perhaps modify the device software to send data to the phone(s) in SMS data message format? Im not sure if it is possible for software to "spoof" an SMS to a phone when it is not a phone itself?
Have the device software upload all its binary data to a ftp/http server that is sitting out there somewhere, have the phone(s) connect to that server and poll for new data periodically?
I'm brand new to android development, basically all I want to do is grab this binary data from the device on my phone and parse/display it over google maps. How do any of those ideas sound, or is there a much easier way I am overlooking? Thanks!

Is it possible for the phone to
connect directly to the device if the
device had some sort of server running
on it, then poll for new data?
Possibly, if they are both on the same WiFi LAN.
If so, what is the protocol needed to
be able to direct connect like that?
You would have to ask the manufacturer of your device. We have no way to know.
Perhaps modify the device software to
send data to the phone(s) in SMS data
message format?
If it is a GSM phone or a CDMA phone, perhaps this would work.
Have the device software upload all
its binary data to a ftp/http server
that is sitting out there somewhere,
have the phone(s) connect to that
server and poll for new data
periodically?
This has the advantage of working with the device over 3G, as the phone and device do not have to be on the same network -- they both just have to be able to reach that server. With Android 2.2, you could also use C2DM to tickle the phone to let it know there is data to be picked up.

For connection type, you can choose between Bluetooth, WiFi or GPRS/3G. What's best for your case depends on how close is the device to the phone and what connection capabilities it have.
You must also decide how connection will be initiated - by phone or by device. The only reliable option for a server on the Android phone is Bluetooth. Wifi is restricted for opening server sockets, and GPRS/3G is carrier dependent. If the device runs a server, you can access it via WiFi if it's on the LAN or Internet, for GPRS/3G it has to be on Internet.
Once you choose these things, you're left with the choice for protocol, but it's a long way to it for an answer at that stage.

Related

How to send data between windows and android without being on the same network and without internet?

I'm looking for a (usable and reliable) way to send data from an Android device to a Windows PC. I'm trying to build an app similar to AirDroid, that can transfer files wirelessly between devices and also mirror notifications. I managed to do this via a LAN connection, but I would like to do it without using any network.
It would be best if it would not require the user to do much work.
Any suggestions ?
PS: The devices will be in the same room
If you want to do the transfer without being in the same connection and without using LAN (or any cable for that matter). I could only think of using Bluetooth.
If your app (at both the mobile and PC side) has Bluetooth permission, you can easily achieve the transfer without much user interaction.
However, this only works for short distances (obviously).
If you're looking for long distance communication, internet is your best bet.

Web server on Android with remote access possibility

can someone confirm, that it is possible to create a web server on android device ( which uses 3G or 4G internet ) and access it via internet ( from the remote PC connected to the internet, not from the same local network ).
I know there already are some web servers for android ( iJetty, nanohttpd ) and the programms like ksweb, so it seems, that it should be possible.
However, I've done some searching in the internet and some people warn, that mobile devices work using NAT protocol, so it would be impossible.
Can somebody resolve the ambiguity?
Thank you in advance.
No, it is generally not possible. The dealbreaker problem is not with Android, but rather that just about any mobile network provider is going to block incoming connections.
For special purposes, you can do things like have the phone contact a publicly visible remote machine and create a tunnel with something like ssh through which inbound connections can then be sent if there is a server program listening on the loopback interface of the Android device. But this tends to be only useful for things like remote testing.
Were you using wifi you could do this, but you'd need to accept that Android is not designed to promise a high availability of any 3rd-party program. You would need a wakelock to keep the processor running. And you may even need to do things like periodically initiate outbound traffic from the device in order to keep the wifi stack/radio in a fully active mode so that it can accept connections.
Generally speaking, data you want to make remotely available from the device should be proactively uploaded to a mutually visible server. If you want to send requests to the device, look at using something like Google Cloud Messaging which is designed to wake up the device and a recipient application on it in order to deliver a brief message.

Simplest way to pass information between the same application installed on different phones

As the topic name suggests, what I am looking for is to add my android app the option to send data to a different phone running the same application so the receiving phone will process it accordingly.
The obvious option for me was to use app engine and use push notification with the phone number acting as the identifier.
Does a simpler solution exist?
Thanks ahead :)
The best and most robust solution is to have something like your messaging clients, in which Device A sends data to the server, which pushes it to Device B. Device B sends a reply to the server, which pushes it to Device A.
This process has the advantage of retrying the sending without requiring your users to stay connected, as may be required if Device B is offline when A sends a message.
A less foolproof solution is to have a server work as a middle man, and get each device's IP Address, and then open up a direct socket between them. In this solution, you'll lose any data that doesn't make it through.
If the devices are on the same network or in Bluetooth range, you could try Bluetooth or WiFi direct.

How to send Bluetooth data to an unknown device?

I'm asking because I've been facing that issue for weeks.
I need to develop an Android application that can be able to perform an Bluetooth Connection and send data to an Bluetooth Hardware.
Ok, so here's the point:
is it possible to perform a RFCOMM connection to an 'unknown' device?
I mean, is it possible to do this without having any information about the hardware code?
Because i'm only able to modify the AndroidDevice (cellphone) code, for SENDING purposes.
I want to send a byte and make sure it was received, but there's only a sending code.
Could we have some more details? Is the other device accessible by you, as in can the other device know information about the Android device? And what do you mean by a "sending code"?
The Android device can pick up any active Bluetooth device in its range, and know the name and address of those devices. So, if the Android device doesn't know anything about the Bluetooth device it wants to connect to, you can always sort through the list of devices in range, and get its hardware code through that.
See the documentation about Bluetooth, specifically the Finding Devices section:
http://developer.android.com/guide/topics/connectivity/bluetooth.html
I've done a fair amount of Bluetooth work with Android devices and Arduinos, and the Bluetooth library might be a bit of a pain to work with, but it is powerful.
With bluetooth the two devices have a UUID. If you a writing a program that runs on both devices you have them listen for that UUID. When they connect as a client or a server you have a dataInputStream and a dataOutputStream. Then you can push and pull bytes out of those.

How I can send a file from my server to an Android app?

I need to send a file to an Android application from my server. I have the user's IP address saved in a database from the last time he was online.
Does Android have something like listener over the internet so I can send a request (from myserver with the IP) to check if is it the user I am looking for or if the IP has changed?
You may want to look into the Android Cloud to Device Messaging Framework. You could use this to tell your app on the Android device that there's new content to fetch from the server, for example.
IP Addresses on mobile devices are pretty ephemeral. In addition, to save on battery power, a lot of phones turn off the wifi antenna when it isn't being used. And of course, internet connections are always spotty on mobile devices.
Because of this, it's usually a lot simpler for the device to ask the server "is there a file for me?". A good way to do this on Android is to use the AlarmManager and have the device periodically check to see if there is a file that it should download - maybe once or twice a day.

Categories

Resources