HDMI μ°κ²° μνλ₯Ό νμΈν΄μΌν μΌμ΄ μκ²Όλ€.
/sys/devices/virtual/switch/hdmi/state
/sys/class/switch/hdmi/state
λ κ²½λ‘μ state νμΌμ ν΅ν΄ HDMI μ°κ²° μνλ₯Ό νμΈν μ μλ€.
/**
* Checks device switch files to see if an HDMI device/MHL device is plugged in, returning true if so.
*/
private boolean isHdmiSwitchSet() {
// The file '/sys/devices/virtual/switch/hdmi/state' holds an int -- if it's 1 then an HDMI device is connected.
// An alternative file to check is '/sys/class/switch/hdmi/state' which exists instead on certain devices.
File switchFile = new File("/sys/devices/virtual/switch/hdmi/state");
if (!switchFile.exists()) {
switchFile = new File("/sys/class/switch/hdmi/state");
}
try {
Scanner switchFileScanner = new Scanner(switchFile);
int switchValue = switchFileScanner.nextInt();
switchFileScanner.close();
return switchValue > 0;
} catch (Exception e) {
return false;
}
}
ν μ€νΈ ν΄λ³΄λ HDMI λΊλ€κΌ½μλ€ν΄λ μ μμ μΌλ‘ μνλ₯Ό μ μ μμλ€.
κ·Όλ° μ€μ νλ©΄μμ μ‘μΆμ νκ³ μλμ§λ₯Ό νλ¨ν΄μΌνλλ°..
HDMIλ μ°κ²°ν΄λ¨μ§λ§ λμ€νλ μ΄λ₯Ό μΈλΆμ
λ ₯μΌλ‘ λ€λ₯Έ νλ©΄μ μ°κ³ μλ€λ©΄..?
μ°Ύμλ΄μΌκ² λ€ π’
** μ°Έμ‘° : Stackoverflow
https://stackoverflow.com/questions/8644665/how-to-check-the-hdmi-device-connection-status-in-android