I am new to android app development. My app needs to broadcast a message on the local network with some data in it. Every device on the network gets this message. The app running on the receiving devices, based on criterion specified in the message, respond back to the sender.
Is it possible to achieve this? If not, is there some alternative to it?
Can the messages be broadcast to multiple networks?
I'd look into Intents and Broadcasts. I'd provide a bit more information than this but this sounds a little like a 'homework question'....i.e. you've not provided enough information as to what you're trying to achieve.
They can't be broadcast to multiple networks from what I know. But look into Sockets and MulticastSockets. You can also check out the API for java.net (also known as network programming)
Related
I want to make an application is via WiFi would send and receive data without sending them to a specific recipient. I explained to the example of a simple chat: The user sends a message via WiFi, but without a specific destination. As a result, his report available to all users nearby. Similarly other users can receive and send messages. I also want to realize the function of repeater, where each user's device not only receives a message from the other devices, and retransmits them to others allowing increase the coverage area of WiFi connection.
But at the moment it is not possible to send data without a specific recipient. The same WiFi Direct necessarily require pairing before data transfer. Can not specify that the recipient is unknown.
Recently I heard the news about the technology WiFi Aware, which involves greater interaction between WiFI devices. Please reply, WiFi Aware allows to do what I described above? Namely - the transfer of data and we will without a clear indication of the recipient and the need to do additional work (eg preliminary pairing between devices).
If WiFi Aware allows to do what I described - when it is expected to release its API? In particular, for Android devices. And if not - you can tell me how to implement what I need? And in general - it is technically possible?
Thank you for your time and sorry for my bad English.
You should try to look into nsd via wifi-direct. This Network Service discovery via Wifi-Direct. What this helps you to achieve is broadcast information to all listening devices.
On the device which wants to convey the information you addLocalService and on the other devices you should discoverServices. In the ServiceInfo object you can the pass the information you want to communicate to the other devices who are listening for services. Please try to study from the link attached above.
I am not very sure about how repeater will work with this.
Currently I am trying to implement a feature where if I do some action in my app on one android device (changing channel on android tv), it should trigger my another android device in close proximity to launch one of its application.
I was just wondering which could be the easiest way to prototype it? Should I need to send some kind of push notification or another simple solution is possible? I just need it for prototyping as of now.
Thanks
You can use GCM with XMPP protocol that allows device-to-cloud connection. In the documentation you will find examples, just read it through.
This technique is very often called device to device but it's actually about upstreaming to the server and telling the server to push notification.
Requirement for both apps would be to use the same GCM sender ID.
Since this is a prototype you don't actually need to check if device is close to you or not. Otherwise, you could frequently update device's location on the server.
I think you want to develop a application like airdroid
https://play.google.com/store/apps/details?id=com.sand.airdroid&hl=en
As i know it set up small http server in one phone. And Send request from an another device. As you want. This sample help you to create such kind of http server. There is one restriction both device must be in same network.
https://github.com/NanoHttpd/nanohttpd.
I need that my app will send a string to another android device and on the receiving android device side i want to make something with that string.
How can I use BroadcastReceiver with the callback OnReceive() just to program the string that he will get Without using the GCM if it is possible.
Thanks.
BroadcastReceivers are for intra- or inter- application communications on a single device. To send messages between discrete devices without a cloud-based solution (such as GCM) then you'll be looking at using the Bluetooth stack for ah-hoc networks or the NetworkServiceDiscovery APIs for devices on the same local network.
Depending on your use case, there are examples to get you going under each of the provided links.
I need to develop an application which sends notification to other device based on current action.
The device on which I need to send notification that might be iOS device or Android device too I am not sure which device he/she is using.
I know about remote notification and push notification in Android and iOS respectively which work for either for Android or iOS only.
But I dont know about the notifications which can work between these two different OS, so If anybody can help me, it would be a great help.
Your query is sounds different and tricky,
There are two alternative to achieve this task.
First thing you can use Web-Service and sending and receiving
request & response as per that platform code. like request parmas should be fix and base on that you have to read that response.So,it could be easy task.
Next way is long and complex.Like create background Bluetooth connection sending your message to other device either it could be message or file.If you are sending a file then you have to read via file stream.
But second trick have limitation and that is area both device should be in Bluetooth range.
So, i would like to prefer first way to achieve your task.
I think you can create a web service that will use GCM (for Android) and Push Notifications for (iOS). This is the standard way the notifications are created, but you can do other interesting stuffs with it, something like, you register your device by sending the notification tokne, OS, and a name or other details that your app stores or display and in response you get similar users/data which you can notify. When you want to notify a device/user/etc, you just send a request to the server with the name/user (something unique) and the server will get the token from the database, the OS, and will decide what to use GCM or push notificatiom, and the device will be notified.
Also there are a lots of tutorials for implementing GCM notifications and push notification, both on server side and mobile side
"Next way is long and complex.Like create background Bluetooth connection sending your message to other device either it could be message or file.If you are sending a file then you have to read via file stream."
But still do you think it's possible to achieve ?
In some case it can be usefull, let me explain. For people (like me) who have a 5" smartphones or more (ascend mate 6.3"), they could be tempt to let their huge phone in their bag, unless you have giant pockets. So let say you also have an ipod touch in your pocket and the huge smartphone in your bag, your ipod touch can be able to inform you if you have received any mails, text, phone calls or any notification you can imagine.
Well I hope understand what I'm thinking of.
I will have two android tablets working in the same retail location, both connected to a local network.
A customer will use one tablet to place an order. That tablet needs to send a notification to another tablet when the order is placed.
I am using a MySql database, and I could poll constantly from the tablet that needs to receive information, but that would drain the battery.
I could use C2DM, but it is absolutely necessary that the system works even if there is an internet slowdown/loss of connectivity.
How can I do what is basically C2DM over a local network from android device to android device? No android device will have cell phone service.
You've asked a general question so the best I can do is give you a general answer. Traditionally, Long Polling has been used in this situation. Essentially, the first tablet polls the second tablet. When the second tablet gets the poll request it just sits on it until it actually has something to tell the other device. Once it has a message to send to the other device, it responds to that initial poll request.
Before the introduction of C2DM we used the XMPP protocol to provide Push Notification.. the best library to acomplish that function was asmack.
Althought, C2DM works perfectly with loss of connectivity (when you reconnect you receive the missed messages)