我一直在寻找,但似乎没有办法。但..
蓝牙设备的连接状态是否有任何意图过滤器?我试过用。 BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED
但是从未收到过。是的我注册了意图过滤器。
在logcat中,我看到BluetoothService在设备连接后立即对“UUID”进行回调,结果为1,但没有收到任何操作
答案 0 :(得分:0)
尝试下面的内容,
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)