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.
Related
I want to send notification from one android device (android tv without bluetooth, telephony) to another android device (phone/tablet). Both are on same wifi network. Through the notification, I want to launch an app or open a page in phone/tablet browser.
I went through GCM messaging and also saw some options where we can have a kind of http server on the phone running but could not understand implementation.
Can someone help with idea and if possible, some piece of code as well.
As I need it for demo, so even any hack solution is fine for me :-)
Thanks for any help or reading.
Your best bet as a hacky solution is to do simple Socket connection between two devices. Since they are on same Wifi, it will be simpler and won't have any firewall restrictions.
Avoid GCM, it requires setting up a GCM Server and then complex registration. It also makes your solution dependent upon Internet connectivity & Google ofcourse.
See an example here:
http://android-er.blogspot.in/2014/02/android-sercerclient-example-client.html
Basically one device such as TV can be a socket listener. The phone/tablet can connect to that socket and then you can initiate a notification on either device based on your requirements and data exchange.
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 have already implemented a push notification system for the android. My system works as following: From my server I communicate through the Http protocol with the google servers. Then the google servers are sending the notification to the mobiles. So, I was wondering if there are any alternatives ways to implement this functionality. However, I want something which will be reliable.
P.S. I would like to hear opinions from people that they implement something similar.
Not sure why you're looking for something else, if you've already got it working through the Google servers, but a good system to send push notifications easily is Urban Airship.
I was working with some Chinese tablets that could not receive android push notifs (very annoying). I had to implement a Comet like system on android.
Basically, on the android device, I created a service which essentially polled a URL. But since polling is very battery intensive, I used a push technique called long-polling. I had the Android http client set a very long timeout. I then on the server side had the server hold the connection open also for a very long time. What would end up happening is that as soon as a message had to be passed, the connection would finish, and the android device would get the message immediately. This is just an additional method of "push" technology.
The only other option not discussed here is a persistant TCP/IP connection. This can be very dicey because Android could kill the service at will, and it can be somewhat battery intensive as well.
From my experience, GCM is the best method out there, and I wish there was something as good as it available for iOS Devices!
Does anyone know how to implement communication between 2 android devices over the internet without using App Engine? For example, I have 2 Android devices, and I want to send a stream of data from one to the second one over the internet. I would like to know, if someone could give me an idea, how could I identify the second device (or how to create a communication channel between two devices ), so I could initiate the transfer (this is not possible using IP addresses ?).If i were to have my own server, which is the best way to go to accomplish this? If someone could point me to some useful resources I would be grateful.I have some background on android programming.
One way I was thinking to accomplish this was to write an android application, and when the user enters it, it will start a service. This service will then listen for network events and registers on my own server with the username and the IP address of the device as available.When another device wants to send data, it will connect to the server, search for the target device (by username key), gets the IP address and sends the data. Could this work, or does anybody have other suggestions?
One way I thought about doing this is making
(excuse the spelling mistakes if any)
It would help if we knew what kind of data you were trying to transfer.
For small bits of information, like notifications, events, and the like, I would suggest doing an HTTP POST to a server that has C2DM capabilities, and using the server as an intermediary.
For larger data, the only way I can think of to do it is to set up a SyncAdapter, then upload the information to the server. The delay will be a bit longer, but you'll reliably get the information downloaded from the server to the phone. So less of a communication API and more of a dropbox for phones.
I haven't done much with NFC, but that may be something you want to look into.
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.