我一直在尋找一段時間,似乎沒有辦法。但是..藍牙連接狀態
是否有任何意圖過濾藍牙設備的連接狀態?我試過使用。 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
你檢查了我提供的鏈接嗎? 「尋找設備」主題似乎是你問的問題! –