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 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!
Is there any way to send request from a server to an Android phone? Actually, I want to control an application (enable or disable some features of the application) in an Android phone by a server. Can I use the IP Address of the Android device?. Can anyone guide me.
Thank you!.
Much simpler way is for phone to contact server and ask should features be enabled. You could also use something like this http://code.google.com/android/c2dm/ but I'm not sure if this is an overkill for your use case.
If the above option is not suited for your case then you can create a simple service
for your application and then attach to application.
The service can be a thread which sends requests to the server with some time intervals that you find suitable and can check if there is anything to check and to do for the application.
And also can run in background.
All push services are usually implemented as well concealed polling. Phones on 3G networks usually sit behind NAT proxies and are not visible to outside world. The same holds for most wlan networks - so either use C2DM, or write your own service polling config information from some server provided by you
So I asked something similar yesterday and did receive an answer to my question, however I don't really think I asked it correctly and therefore didn't receive the exact information I needed.
I'm in search of an API, some open source code, or even just a way that someone else has achieved this on the Android. I'm making an app that needs to find all other Android devices within a specified radius. For example, when you open your Android Google Maps App, and you search for say "Restaurants [ZipCode]", it uses a radius modified from your zip code and finds all of those places. The GPS gets YOUR location, and maps uses that information to find restaurants within an address close to that passed in location.
Instead, I want to be able to use the GPS to find my location (as it can now easily), but instead of finding things on a map (which is already built in), I want to be able to find other GPS enabled Android phones. I get that they will have to be broadcasting their GPS signal at the same time as well (since they don't have their data stored with some sort of central database as a restaurant would). However, I don't just want to FIND these phones, I want to send/receive data from these phones (with correct permissions obviously).
Now, I've found things like the Bump API. However, BUMP uses the phones sensors to spark this search. So basically, if you "bump" your phone with another and have the app running, it will THEN go ahead and use GPS to find the location of the other phone you just bumped with and exchange data between them. This is like EXACTLY what I want to do however in their API, they do not provide the functionality to just say, "Hey, give me all phones within a mile from me."
I've also found API's that can do exactly what I need but they have to be on the same Bluetooth range or on the same Wi-Fi network, which doesn't suit what I need at all.
Do you guys know of anything that can fit exactly what I need that already exists? Or a way to maybe modify Bump API (if you've done it), to not have to use the phone sensors and find phone information directly through GPS for phones around you? Or is there something that exists over a 3g/4g network instead of only wi-fi/Bluetooth?
Thanks guys.
Instead of frequently posting locations to an external server, couldn't the GPS realize other things broadcasting a GPS signal at a very specific time and send/receive data from them?
The only things that are "broadcasting a GPS signal" are satellites.
We would like to accomplish this without the use of an external server.
You have no choice but to use an external server, whether you like it or not, both for discovery and for later communication.
Do you guys know of anything that can fit exactly what I need that already exists?
Foursquare, Google Latitude, Yahoo Fire Eagle, and so on.
To do this via GPS, you would have to have all the phones frequently posting their locations to a network server, which could then inform them of others nearby.
Needless to say this would be opt-in only!
And it may have negative consequences for battery life, unless you make it update infrequently, which may limit its usability.
The advantage of having an explicit trigger action to both phones is that they only need to query the GPS and inform the server to find each other by location when they've both been triggered.
You would probably have to author your own application - then you could do this server-side and push things. If you're trying to push data to random Android phones - you're out of luck. Most people aren't going to want this, and probably aren't going to have the apps necessary to receive and understand it. With Bluetooth networking you'd need authorization, and most Androids don't have a capability to transfer random data by Bluetooth out of the box (though you certainly can get software to do it).
Honestly, malware and tracking are the reasons this really isn't possible, but even if they weren't, you would still need an application on the receiving devices that understand what you're sending them. And if you're widely spread enough, you'd probably want to send it to a server to disseminate anyway (for the transmitting phones bandwidth costs at least).
Develop a server application that your android app logs into. Send the GPS location every time the phone moves over a present distance. Either send a query request to the server to ask it if any other phones are in range, or get the server to inform the phone of a new device in range.
You may run into server scalability problems, so thats something to think about.
Also, this would be a big battery drain, and so your users may not be too keen to run it, not to mention the privacy element.
You need to rethink what you're trying to do. Android devices don't "transmit" any GPS signal, they are simply receivers, with signals from satellites. So the phone can easily get a location for itself, but the location of other devices is very, very private information. To get access to location for other phones, you either need to be on the same network as them (bluetooth, wifi), or you need them to use a server-based service to send locations to, like Google Latitude.
I'd be highly unlikely to sign up to a service like that. My location is very private, I share it with some people, but I cannot seem myself openly sharing it with an app, without a very, very good reason.
It seems to me that you need to build a server-based application, e.g. on Google App Engine, have people sign up, and agree to their location being sent to that server, so other phones running your app can access that information from the central store.
The question now has a very simple solution to it. All you have to do is set up a Geofence and monitor it for entry and exit of users. Geofence allows you to choose a geolocation and set a circle of desired radius around it. When someone enters or exits the location you can get notified and perform desired action.
Visit this link for further details on how to use this in Android.
All the comments from other folks about not being able to pick up the signal from others phones are correct. There is a completely different alternative system however in the network based location services. This is a model where you ask a carrier network for the location of a handset, which the carrier network needs to track for enhanced 911 service in the US (I'm unaware of how widely deployed this is in other areas, and how many different services you would need to use to cover other areas).
It's potentially a very expensive route however. And it won't just automatically work for all handsets, I believe the users will have to be opted into sharing location with your service. This is how services like Loopt had initially setup their location info so that it could be passively collected without negatively impacting handset battery life. There are some third party services that front for a cross-carrier service such as Location Labs:
http://locationlabs.com/
As well as third party location services like Skyhook Wireless, who might be able to get you some info of the sort (though I don't think what you're looking for maps to any of their existing APIs)
I installed today from Market, the Yahoo Mail application and I was reading it offers push message notification technique. Indeed it works, as I got exactly the same moment the alert on my desktop computer and my mobile mail client.
How is it accomplished?
There already is another question discussing how to implement push notification without the cloud to device messaging in older system.
There are several frameworks that give you push abillity. They all require a running a small background thread that is polling a server at a very short interval(Bad for data rate and battery) or keep an open connection to a server that is kept alive somehow and the client is notified every time a new message is waiting on the server.
Have a look at the question and maybe choose on of the mentioned frameworks, the frameworks will reuse the same service for all applications that are installed on the phone using the same framework and therefore save battery and general system usage.
Soon, you will be able to use the Cloud-to-Device Messaging (C2DM) system, though it will require Android 2.2 or higher. You might also want to watch the Google I|O 2010 conference presentation on it, which gives a few clues as to how they implemented it.
Without installing the app, setting up my router to capture packets, and doing some packet inspection I can't tell you exactly how they do it. At the lowest level it's as simple as keeping an open TCP connect to a remote server and having the server sending the client a packet when it needs to do something. My educated guess on the specific way they are doing it is either with IMAP IDLE, or XMPP.