2
votes

I am trying to add "HDMI connection" check in my app.

I referred to How to check the HDMI device connection status in Android? and decided to add the checks to read /sys/devices/virtual/switch/hdmi/state or if not, /sys/class/switch/hdmi/state files.

But I am getting:

java.io.FileNotFoundException

with "Permission denied". Do we need to request some permissions for this kind of access?

Thanks, Vinay

1

1 Answers

0
votes

I stumbled across the same problem.

  1. resolve permissions problem
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

READ should be enough but if you grand Write works the same.

  1. resolve runtime permmision problem - if you work with API 23+ you have to ask permission on runtime.

  2. Root device - I had to root device to access sys/class/switch/*