Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
618 views
in Technique[技术] by (71.8m points)

sockets - How to send and receive data in Android Programming using bluetooth without pairing?

I am new to Android programming, and have java concept, I want to know that how can I send and receive data using bluetooth without pairing or any password (Only if both device has my app installed), any suggestion?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As far as I know it's impossible to send or receive data over RFCOMM sockets without pairing. I've tried this extensively with an application that I'm developing. My results are:

  • If the two devices are paired and discoverable, bi-directional communication is possible
  • If the two devices are paired, but the "server" device (the one the android device is trying to connect to) is set to be not discoverable, then bi-directional communication is still possible
  • If the two devices are not paired, but the "server" device is discoverable, then a pairing request is still required before bi-directional communication is possible. This means that RFCOMM client sockets (i.e., those from Android) require the devices to be paired. This was tested on a Samsung Captivate running Android 2.2. I find this very strange, as I can understand requiring pairing before allowing RFCOMM server sockets, but requiring pairing for client sockets is a bit stringent.

As @ethrbunny mentioned you can also just use WiFi, setup parallel server/client threads on each device, and send whatever you want. To discover services on a local network you can optionally use zeroconf.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...