通过蓝牙,在两台设备之间传递音频(包括音乐,通话)。
主要代码实现:
public class BluetoolsPhoneUtil {
static String TAG = "BluetoolsPhoneUtil";
private static String filePath = "/sys/class/gpio_ctrl_class/gpio_ctrl_device/gpiopd28";
/**
* 操作Bluetooth
*/
public static void ctrlLedLight(String flag) {
try {
FileOutputStream outputStream = new FileOutputStream(filePath);
outputStream.write(flag.getBytes());
outputStream.flush();
outputStream.close();
} catch (Exception e) {
Log.d(TAG, "Exception:" + e.getMessage());
} finally {
}
}
/**
* 开机的时候打开Bluetooth
*/
public static void startLedLight() {
try {
ctrlLedLight("1");
Thread.sleep(5000);
ctrlLedLight("0");
} catch (Exception e) {
}
}
/**
* 接听/挂断电话改变Bluetooth状态
*/
public static void changeLedLight() {
try {
ctrlLedLight("1");
Thread.sleep(200);
ctrlLedLight("0");
} catch (Exception e) {
}
}
}
主要代码实现:
public class BluetoolsPhoneUtil {
static String TAG = "BluetoolsPhoneUtil";
private static String filePath = "/sys/class/gpio_ctrl_class/gpio_ctrl_device/gpiopd28";
/**
* 操作Bluetooth
*/
public static void ctrlLedLight(String flag) {
try {
FileOutputStream outputStream = new FileOutputStream(filePath);
outputStream.write(flag.getBytes());
outputStream.flush();
outputStream.close();
} catch (Exception e) {
Log.d(TAG, "Exception:" + e.getMessage());
} finally {
}
}
/**
* 开机的时候打开Bluetooth
*/
public static void startLedLight() {
try {
ctrlLedLight("1");
Thread.sleep(5000);
ctrlLedLight("0");
} catch (Exception e) {
}
}
/**
* 接听/挂断电话改变Bluetooth状态
*/
public static void changeLedLight() {
try {
ctrlLedLight("1");
Thread.sleep(200);
ctrlLedLight("0");
} catch (Exception e) {
}
}
}
其中调用startLedLight()方法,即可。