我正在创建一个应用程序,通过 HDMI 电缆将 android 设备连接到电视,在电视中播放视频。我想使用 HDMI 电缆检测电视是否已关闭。我还尝试了此链接中提到的方法,但它不起作用。 如何在 Android 中查看 HDMI 设备连接状态?
问问题
4359 次
1 回答
0
从位置/sys/class/display/display0.hdmi/connect 获取数据文件。如果文件中的数据为0 hdmi 不连接如果它的1 连接。试试这个方法。
尝试 {
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();
}
于 2014-03-06T10:41:47.513 回答