1
我正在通過HDMI電纜將Android設備連接到電視,創建一個應用程序,其中視頻在電視機中播放。如果使用HDMI電纜關閉電視機,我想檢測電視機。我也試過這個鏈接中提到的方法,但它不起作用。 How to check the HDMI device connection status in Android?使用HDMI電纜開啓或關閉Android設備
我正在通過HDMI電纜將Android設備連接到電視,創建一個應用程序,其中視頻在電視機中播放。如果使用HDMI電纜關閉電視機,我想檢測電視機。我也試過這個鏈接中提到的方法,但它不起作用。 How to check the HDMI device connection status in Android?使用HDMI電纜開啓或關閉Android設備
獲得從該位置的數據文件/sys/class/display/display0.hdmi/connect.If在文件中的數據是0 HDMI是不如果其1個其connected.Try此方法連接。
嘗試 {
File file = new File("/sys/class/display/display0.hdmi/connect")
InputStream in = new FileInputStream(file);
byte[] re = new byte[32768];
int read = 0;
while ((read = in.read(re, 0, 32768)) != -1)
{
String string="Empty";
string = new String(re, 0, read);
Log.v("String_whilecondition","string="+string);
result = string;
}
in.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
我認爲這取決於在設備上,我看不到我的設備上的/ SYS /班/顯示。 –
是的,這取決於製造商,但大多數設備將擁有這些文件。 –