Is there any api to check whether bluetooth is on or off?

Appium 1.2.2
Java 1.6.2

My Application under test has policy to disable the bluetooth. Is there any way with appium to check whether bluetooth if on or off.
I see networkconnection settings API that gives wifi, data and airplanemode off or on.
Similarly is there an API to check blueooth?


Native automation libraries do not yet support bluetooth setting detection.

A workaround is to open the Settings package/activity and look for the toggle.

Hi Jonahss,
I have opened the settings tab, by initializing the driver with settings app. How to get the toggle value off or on?

The below code clicks on Bluetooth Text button. And it goes to the next screen of bluetooth?
How to get only toggle value of Bluetooth?

WebElement button=driver.findElementByName(“Bluetooth”);

			String text = button.getText(); //giving Bluetooth
			boolean status = button.isEnabled(); //true but this is not toggle value
			if (button != null){
				TouchAction ta = new TouchAction(driver);		
				TouchAction y = ta.moveTo(button).tap(button).perform(); //taking to next screen related to bluetooth, to show any devices to scan etc.

From the screenshot, The resourceid of all toggle values seems same. So how to exactly get the off/ on value of blueooth only?


Well it looks like there’s a label under bluetooth that says “off”. TextView.Off I see. So maybe just look for the element, and check if it exists.

This is on HTC device. But Samsung we do not have “off” text below Bluetooth. We need to find a way unique to all devices.
So i was thinking how we can get the toggle value right side to the bluetooth button.

Is there a way to get the value of the element which is at the RIGHT-hand side of the bluetooth element?
FYI, the element at the right hand side has attributes (screenshot in above discussion) like checked. if blueooth is on, the checked value is true, otherwise false. How to get this value?


You can get the attributes of an element. Or look at the xml dump which the pageSource provides.

I am not seeing any get method to get all the attributes of the element. I see getAttribute(String) in JAVA client. But passing “checked” as parameter to the function always giving false.

Is there any way to get the attributes of the element?

Is there any way to get the attributes of the element?