【问题标题】:Android device to detect display is on or off using the hdmi cable使用 hdmi 电缆检测显示的 Android 设备打开或关闭
【发布时间】:2014-02-20 11:21:28
【问题描述】:

我正在创建一个应用程序,通过 HDMI 电缆将 android 设备连接到电视,从而在电视中播放视频。我想使用 HDMI 电缆检测电视是否已关闭。我还尝试了此链接中提到的方法,但它没有在职的。 How to check the HDMI device connection status in Android?

【问题讨论】:

    标签: android hdmi


    【解决方案1】:

    从位置/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();
    
           }
    

    【讨论】:

    • 我认为这取决于设备,我没有在我的设备上看到 /sys/class/display。
    • 是的,这取决于制造商,但大多数设备都会有这个文件。
    猜你喜欢
    • 2020-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多