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.
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 was wondering whether I can receive broadcast packets at MAC level (L2-WiFi) on Android AND deliver such messages to my application which will parse the payload of such packets.
The MAC interface parses all these packets by construction (e.g., beacon); however, I don't know if (where) I can register some "callback" to be invoked whenever the node receives a broadcast packet (i.e., ff:ff:ff:ff:ff:ff) which is not a management WiFi Frame.
The idea is to have access to some information immediately, possibly even before authentication/association, or if that is not feasible, soon after association and before DHCP has assigned and IP address to my interface.
Yes, there are tcpdump/wireshark like programs but need root privileges,
while we are looking for a regular way (user privileges) to do it.
Thus, access points can send some information via broadcast packets,
and clients can receive and parse such information, performing some actions
Any Idea?
Thanks
It seems that there is no way supported by Android SDK API to do that.
Such APIs show just functionalities over level 3, IP.
Thus, it seems to me you cannot access to level 2 in a transparent way.
Actually, I didn't have a look at Android NDK, but I will
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)
I want to send and receive information between Emulators in Android.i am using two systems and i have installed android in both the systems and i have to consider one emulator as server and another as client.Now i want to send data from one to another.Anyone knows regrading this please help me with some sample code.
What sort of information do you want to send between the emulators?
You can transmit SMS messages, or simulate phone calls, from one emulator to another using the target emulator's console port number as the number to dial. The Android Developer Site describes the process in more detail under "Sending a Voice Call or SMS to Another Emulator Instance"
If you want to transmit data, unfortunately Android doesn't currently provide any P2P or Instant Messaging APIs, so there's no generic technique available through the SDK you can use.
Your best alternative is to create your own server-based solution (or your own P2P API, though that might be a little more complicated).
Take a look at Java Socket.