How can I remotely start an activity in a different android device using Bluetooth? Is there any way? If so can anyone suggest sample code?
you mean "take control over another phone" in other terms ?
Bluetooth would be the mean of physical connection, but i don't know if implementing your own server on Android and thus handling operations like starting apps and so on would be an easy thing... and i'm voluntarily not speaking about security issues ? any experts in there ?
Yes, you can do this, it's pretty easy once you're familiar with bluetooth. You'll have to make server/client connection on both devices with bluetooth (RFCOMM). The client will send a message to the server (by pressing a button or something), server parses the message and executes (starts a certain activity). Take a look at the BluetoothChat example.
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.
Im a little new to the android development, I believe I have the basics down but I am wondering the best way to communicate between two phones running the same app. I am looking for something that would be close to instant. For an example, if you sent a message or somekind of variable or string it would appear on the other phones app providing the app was open on both phones. Would be great if I could be pointed in the correct direction here, Thank you!
Assuming you have access to a server that both devices can connect to, the best way to handle this is to set up a socket and have both devices connect to it. That way the messages can be send back and forth and be pushed through immediately (rather than the devices polling for any new thing to do intermittently).
You can learn more about using sockets on android here: http://developer.android.com/reference/java/net/Socket.html
If you're unfamiliar with how to write a server socket, you can write something that works somewhat similarly with a system that just has each device leave a message and have the other device come looking for it, but as I said, that is much less "real time" since then you have to have the devices constantly pestering the server to see if there's anything new to do.
There are also kludgy ways to create a fake socket behavior whereby the http connection never closes and you just keep sending data down the pipe, but if you can avoid it and just use a socket, you should.
Although I feel like this question has been beat to death. I still haven't found a definitive answer. But now, I'm going to try and make things a LITTLE more specific, maybe some of you bluetooth gurus can put it in terms I can understand!
Is it possible to have simultaneous bluetooth connections? For example, phone A sends data to phone B, then B sends that data to phone C, who then sends it back to phone A.
If this is possible, the phones would need to have multiple (at least 2) bluetooth sockets open at one time.
If this is not possible, do you know if it would be possible close a socket, and open another quickly enough to simulate this functionality? (given that the phones are already paired)
Let me know what you think!
Thanks!
For iPhone, you can use GameKit's peer to peer mode for this.. it's a bit confusing but it works:
https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/GameKitConcepts/GameKitConcepts.html#//apple_ref/doc/uid/TP40008304-CH100-SW1
Client/Server GKSessions
But note that it is not (or nearly not) possible to connect iOS with Android via bluetooth (unless you create an app for jailbroken devices)
A few months ago I have coded a messenger program in C# which enables many clients to connect to a server and have a chat.
Now, I want to code the same program for android. After reading the bluetooth article in Android Developers, it seems that this is possible for a device to hold many bluetooth sockets at the same time + be discoverable (I'm talking about the server). The only action the said that should not work togather with bluetooth sockets is discovery, but since the client runs that, it doesn't change much.
But what made me unsure if it's possible to be done, is the fact that there is NO such an application in the android market! (Atleast not after a quick check.) There are many bluetooth chat apps, but none of them allows multi clients.
So before I begin coding that, I want to make sure it is possible, and make sure that holding, say, 5 tcp sockets won't kill the server phone.
Thanks in advance :)
Here is a link I found:
"Multi-device extension of the official Android Bluetooth Chat example"
Is that what you wanted?
I am doing a project where I have too develop an application that listens for incoming events by a service. The device that has to listen too events is an Android phone with Android SDK 1.5 on it. Currently the services that call events only implement communication trough UDP or TCP sockets. I can solve my problem by setting up a ServerSocket, but i doubt that's the most power efficient way. This application will be running most of the time, with Wi-Fi on, and I'd like too reach an long battery duration. I've been looking for options on the internet for my question for a while but i couldn't get a real answer. I've got the following questions:
What is the most efficient way too listen to incoming events? Should I make an ServerSocket? or what are my options?
Are there any other implementations that are more power efficient?
Ive been also thinking of implementing communication trough XMPP. Not sure if this is the best way. I'm not forced too an specific implementation. All suggestions are welcome!
Thanks for the help,
Antek
You already listed the possible choices. If the app has to be able to handle events, it also needs to be running all the time. afaik there is no push-notification-service that automatically calls your application, like on the iPhone.
I think using a protocol like XMPP is the most easy solution. Having your own ServerSocket would also mean the server has to send requests to different IPs whenever you are switching your network.