android检测hdmi已接入,如何检查Android中的HDMI设备连接状态?
Ivan Morgill..5我最终出来了.它正在使用S3和S4.它应该适用于任何4+ Android版本.public class HdmiListener extends BroadcastReceiver {private static String HDMIINTENT = "android.intent.action.HDMI_PLUGGED";@Overridepublic void
Ivan Morgill..
5
我最终出来了.它正在使用S3和S4.它应该适用于任何4+ Android版本.
public class HdmiListener extends BroadcastReceiver {
private static String HDMIINTENT = "android.intent.action.HDMI_PLUGGED";
@Override
public void onReceive(Context ctxt, Intent receivedIt) {
String action = receivedIt.getAction();
if (action.equals(HDMIINTENT)) {
boolean state = receivedIt.getBooleanExtra("state", false);
if (state) {
Log.d("HDMIListner", "BroadcastReceiver.onReceive() : Connected HDMI-TV");
Toast.makeText(ctxt, "HDMI >>", Toast.LENGTH_LONG).show();
} else {
Log.d("HDMIListner", "HDMI >>: Disconnected HDMI-TV");
Toast.makeText(ctxt, "HDMI DisConnected>>", Toast.LENGTH_LONG).show();
}
}
}
}
AndroidManifest.xml需要将其转换为应用程序标记:
这有助于我检测hdmi是连接还是断开,但在运行应用程序之前不知道hdmi是否已连接. (2认同)
更多推荐
所有评论(0)