如何连接到电话和发送文件和放大器;聊天通过蓝牙消息? [英] How to connect to phone and send files & chat messages via bluetooth?
问题描述
我创建一个 Android应用程序
,将有包含两个选项的菜单:
I am creating a Android Application
that will have a Menu
containing two options:
-
通过
。蓝牙
聊天 -
传输文件
通过蓝牙
。 -
配置
包含控件打开蓝牙
关闭
和ON
和能见度
关闭
和ON
Chat
viaBluetooth
.Transfer Files
viaBluetooth
.Config
containing controls to turnBluetooth
OFF
andON
, andVisibility
OFF
andON
1)我所做的聊天,现在它的工作原理,但我已经使用的方法我不这么认为这是完全正确的。
1) I have made the Chat and now it works, but the method that i have used i dont think so that is totally right.
我有一个按钮,服务器,另一个按钮客户一部手机需要点击服务器,等待其他客户端点击并连接到它。
I have a button "Server" and another button "Client" one mobile phone needs to click server and wait to the other click client and connect to it.
有另一种方式,而不是聊天的这种方式?
There is another way to Chat instead of this way?
我可以提供code越好,但我不知道code,我需要提供什么样的一部分,因为我不能在这里发表的所有全code,可以吗?它的范围太广。
I can provide code as possible, but i dont know what part of code that i need to provide, because i cant post all the whole code here, can i? its too broad.
2)我要转移使用samme连接我聊天使用的文件。
2) I want to Transfer Files using the samme connection that i used on the Chat.
我能做到吗?
推荐答案
也许的 Android的蓝牙教程可以帮助你。
和本教程说,你怎么能设备之间发送消息和文件:
蓝牙数据传输
And this tutorial say how you can send messages and files between devices: Bluetooth Data Transfer
不过,基本上是:
你需要这个权限添加到您的manifest.xml文件:
But, basically: You need add this permission to your manifest.xml file:
<uses-permission android:name="android.permission.BLUETOOTH"/>
和您的创建事件可能是这样的:(但是,所有的codeS是在本教程)
And your on create event could looks like: (But all the codes are in the tutorial)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.txDevice);
MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
ba = BluetoothAdapter.getDefaultAdapter();
if(!ba.isEnabled()){
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivity(intent);
Intent intent1 = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivity(intent1);
}
这篇关于如何连接到电话和发送文件和放大器;聊天通过蓝牙消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!