anroots
anroots

Reputation: 2079

Checking HDMI display status from Android app?

I need to write an Android service that detects when an external HDMI monitor goes offline (or comes back online). The purpose of the service is to notify employees if one of the public TV screens (powered by Android) malfunctions. The problem - as far as I've been able to research - Android has no concept of an HDMI API (although some manufacturers have their own implementations).

The box in use is Android 2.3 HD 1080P Internet TV Box WIFI Media Player HDTV MP3/WMA. My best bet is using the Power or DisplayMetrics API-s to determine if the current screen is HDMI.

Can this be done on Android 2.3?

Upvotes: 3

Views: 5401

Answers (2)

Aj_31
Aj_31

Reputation: 187

You can get the hdmi state from the location /sys/class/display/dispaly0.hdmi/connect. It gives the correct Hdmi connected and disconnected state.

Upvotes: 1

Sasha Nikolic
Sasha Nikolic

Reputation: 770

Only as of Android 3.0 the common sysfs location was included in the sources where you could check if the HDMI is ON or OFF - /sys/devices/virtual/switch/hdmi/state . Before that (like in Android 2.3) vendors were using custom methods. Try to check if your model has some sysfs location where the driver writes this information or check if there are sticky broadcasts related to swiching of HDMI that you can listen to.

Upvotes: 3

Related Questions