【发布时间】:2014-02-20 11:21:28
【问题描述】:
我正在创建一个应用程序,通过 HDMI 电缆将 android 设备连接到电视,从而在电视中播放视频。我想使用 HDMI 电缆检测电视是否已关闭。我还尝试了此链接中提到的方法,但它没有在职的。 How to check the HDMI device connection status in Android?
【问题讨论】:
我正在创建一个应用程序,通过 HDMI 电缆将 android 设备连接到电视,从而在电视中播放视频。我想使用 HDMI 电缆检测电视是否已关闭。我还尝试了此链接中提到的方法,但它没有在职的。 How to check the HDMI device connection status in Android?
【问题讨论】:
从位置/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();
}
【讨论】: