我一直在寻找一段时间,似乎没有办法。但是..蓝牙连接状态
是否有任何意图过滤蓝牙设备的连接状态?我试过使用。 BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED
但这是从来没有收到。是的,我确实注册了意向过滤器。
在logcat中我看到BluetoothService制作回调 “UUID” 与结果1设备连接,但没有操作系统收到
我一直在寻找一段时间,似乎没有办法。但是..蓝牙连接状态
是否有任何意图过滤蓝牙设备的连接状态?我试过使用。 BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED
但这是从来没有收到。是的,我确实注册了意向过滤器。
在logcat中我看到BluetoothService制作回调 “UUID” 与结果1设备连接,但没有操作系统收到
尝试以下之后,
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.os.Bundle;
import android.widget.Toast;
public class BluetoothStatus extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
String toastText;
if (bluetooth.isEnabled()) {
String address = bluetooth.getAddress();
String name = bluetooth.getName();
toastText = name + " : " + address;
} else
toastText = "Bluetooth is not enabled";
Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();
bluetooth.setName("Enrichware");
}
}
详情:http://learnandroiddevelopment.blogspot.in/2011/02/android-how-to-find-bluetooth-status.html
使用IntentFilter,示例:How to programmatically tell if a Bluetooth device is connected? (Android 2.2)
它不是我想知道的蓝牙。它是否连接设备。我知道我可以看到套接字是否连接,但我不想与异步任务和ui线程一起玩,因为我已经取得了进展。我只想知道设备连接状态 – FabianCook
您是否执行权限的东西? ' '其实我建议你按照这个链接。 http://developer.android.com/guide/topics/connectivity/bluetooth.html –
是的,我有。我有设备连接和一切。我只需要一个针对连接的意图过滤器 – FabianCook
你检查了我提供的链接吗? “寻找设备”主题似乎是你问的问题! –