jjzjj

BluetoothDevice

全部标签

蓝牙的Android RSSI值总是返回-32768?

我试图通过单击按钮获取已连接蓝牙设备的当前RSSI值。但是它总是只返回-32768!不知道怎么了!但是,我能够在第一次连接时获得正确的RSSI。privateButton.OnClickListenerbuttonRSSIOnClickListener=newButton.OnClickListener(){@OverridepublicvoidonClick(Viewarg0){//TODOAuto-generatedmethodstubIntentintent=newIntent(BluetoothDevice.ACTION_FOUND);shortrssi=intent.getS

android - 以编程方式使用蓝牙连接两个 Android 设备

我正在做一个蓝牙项目,我想在其中使用蓝牙编程连接两个设备。我正在遵循tfdeveloper.android.com的指南和代码。有人可以帮我解决这个问题吗?这是我试过的代码。谁能告诉我构造函数从哪里接收设备对象?privateclassConnectThreadextendsThread{privatefinalBluetoothSocketmmSocket;privatefinalBluetoothDevicemmDevice;publicConnectThread(BluetoothDevicedevice){//Useatemporaryobjectthatislaterassi

安卓蓝牙--如何 "Undiscover"设备

所以我是Android的新手,正在创建一个支持蓝牙的应用程序。遵循这个非常有用的文档:http://developer.android.com/guide/topics/connectivity/bluetooth.html在其中,他们为ACTION_FOUND提供了一个BroadcastReceiver,它报告任何发现的设备,如下所示。它运行良好。//CreateaBroadcastReceiverforACTION_FOUNDprivatefinalBroadcastReceivermReceiver=newBroadcastReceiver(){publicvoidonRecei

android - 获取android中所有可用蓝牙设备的地址和名称

我可以检索配对的设备名称和地址,但我不知道如何检索可用的蓝牙设备名称和地址?StringoutV="";b1=(Button)findViewById(R.id.button1);b2=(Button)findViewById(R.id.button2);tv=(TextView)findViewById(R.id.textView1);b1.setOnClickListener(newView.OnClickListener(){BluetoothAdapterBadap=BluetoothAdapter.getDefaultAdapter();@Overridepublicvoid

android - 带有传输参数的 BluetoothDevice.ConnectGatt()

我刚开始使用Android,并使用低功耗蓝牙在AndroidStudio中设置了一个API21项目。深入研究BluetoothDevice向我展示了ConnectGatt()方法的两个签名:publicBluetoothGattconnectGatt(Contextcontext,booleanautoConnect,BluetoothGattCallbackcallback)和publicBluetoothGattconnectGatt(Contextcontext,booleanautoConnect,BluetoothGattCallbackcallback,inttranspo

android - 6.0.1 搜索附近的蓝牙

我正在使用一个搜索附近蓝牙的应用程序。我使用以下代码,它在5.0中有效,它返回附近的蓝牙设备但是当我在6.0.1中测试时BluetoothDevice.ACTION_FOUND没有被调用,只有BluetoothAdapter.ACTION_DISCOVERY_STARTED和BluetoothAdapter.ACTION_DISCOVERY_FINISHED被调用。@OverrideprotectedvoidonCreate(BundlesavedInstanceState){BluetoothManagerbluetoothManager=(BluetoothManager)getS

Android BluetoothSocket 连接返回零

我们的设备通过蓝牙发送数据,在android应用中我们需要读取这些数据。我能够建立蓝牙连接,接下来我调用线程以使用BluetoothDevice建立BluetoothSocket连接。此处读取字节时返回0(零)此外,while循环仅运行一次。此外,我在下面的代码中使用的UUID来自一些蓝牙代码fragment。我是否需要获取设备的正确UUID。有人能帮忙吗?如果你给我有用的答案,我将不胜感激。//CallingConnectThreadafterBluetoothispairedpublicclassConnectThreadextendsThread{privatefinalBlue

android - 找不到所有蓝牙设备android

我正在尝试连续显示蓝牙设备并在屏幕上显示它们,但它从来没有向我显示所有设备,而是一次只显示1个。我找不到我做错了什么。这是我的代码,也许您可​​以在其中找到任何问题。谢谢classmonitorBluetoothextendsmonitor{privateListViewmLvDevices;privateArrayListmDeviceList=newArrayList();publicmonitorBluetooth(serviceservice){super(service);bluetooth=BluetoothAdapter.getDefaultAdapter();this.

android - 不使用数据包检测蓝牙 SPP 断开连接

我有一些连接到Android手机的蓝牙设备,但我无法检测到断开连接。除非需要,否则蓝牙设备不会发送数据包,因此不能选择在数据包接收时使用看门狗来检测断开连接。我读过您可以使用ACLDisconnected广播,但是这个事件对我来说永远不会触发(我等了几分钟)。在Android6中检测断开连接的可靠方法是什么?这是我的AclDisconnect注册码:_filter=newIntentFilter();_filter.AddAction(BluetoothDevice.ActionFound);_filter.AddAction(BluetoothDevice.ActionBondSta

android - 如何检查与设备的蓝牙连接是否断开?

我想知道我与设备的蓝牙连接何时断开。我发现这个要检查:IntentFilterfilter1=newIntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);IntentFilterfilter2=newIntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);IntentFilterfilter3=newIntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED);this.registerReceiver(mReceiver,f