簡體   English   中英

藍牙連接狀態

[英]Bluetooth connection state

我搜索了一段時間,似乎沒有辦法。 但..

藍牙設備的連接狀態是否有任何意圖過濾器? 我嘗試使用。 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,示例: 如何以編程方式判斷是否已連接藍牙設備? (Android 2.2)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM