0

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

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
FabianCook
  • 20,269
  • 16
  • 67
  • 115
  • did you perform permission stuff? `` actually I suggest you to follow this link. http://developer.android.com/guide/topics/connectivity/bluetooth.html – Olgun Kaya Jun 26 '12 at 05:01
  • Yes I have. I have the device connecting and everything. I just need a intent filter for the connection – FabianCook Jun 26 '12 at 05:07
  • did you checked the link I provided ? "Finding Devices" subject seems the thing you asking !! – Olgun Kaya Jun 26 '12 at 05:33
  • I didn't see the link but I hadn't tried using BluetoothDevice.Action_Acl_Connected which worked. Must have just overlooked it. Did your link contain this? I cant check it. Using 3G on my phone. – FabianCook Jun 26 '12 at 05:41
  • the link is in my first comment – Olgun Kaya Jun 26 '12 at 05:45
  • I've already read through the that page. Its in the google docs with the sdk. Sorry doesn't answer the question – FabianCook Jun 26 '12 at 05:53
  • Ok I see that. you need to jump to the BluetoothDevice page from there to see the actions. Anyway IF you have solved your problem with the action you mentioned that's the point. – Olgun Kaya Jun 26 '12 at 05:59

1 Answers1

0

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)

Community
  • 1
  • 1
Ponmalar
  • 6,871
  • 10
  • 50
  • 80
  • 1
    Its not the bluetooth I want to know about. Its whether the device is connected or not. I know I can see if the socket is connected but I dont want to be playing around with the async task and the ui thread because I already have the progress as something else. I just want to know the device connection state – FabianCook Jun 26 '12 at 05:09