I've been searching for a while and there doesn't seem to be a way. But..
Is there any intent filter for the connection state of a bluetooth device? I tried using. BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED
but that is never recieved. Yes I do register the intent filter.
In logcat I see BluetoothService Making callback for "UUID" with result 1 right after the device is connected but nothing os received
Try the below,
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");
}
}
Details: http://learnandroiddevelopment.blogspot.in/2011/02/android-how-to-find-bluetooth-status.html
Using IntentFilter, Sample: How to programmatically tell if a Bluetooth device is connected? (Android 2.2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.