public Boolean Issupportmediacodecharddecoder () {Boolean ishardcode = false; Read the system profile/system/etc/media_codecc.xml File File = new file ("/system/etc/media_codecs.xml"); InputStream inFile = null; try {in = new FileInputStream (file); } catch (Exception e) {//Todo:handle Exception} if (inFile! = null) {xmlpullparserfactory PULLFAC Tory try {pullfactory = Xmlpullparserfactory.newinstance (); Xmlpullparser Xmlpullparser = Pullfactory.newpullparser (); Xmlpullparser.setinput (In, "UTF-8"); int eventtype = Xmlpullparser.geteventtype (); while (eventtype! = xmlpullparser.end_document) {String tagName = Xmlpullparser.getname (); Switch (eventtype) {case XmlPullParser.START_TAG:if ("Mediacodec". Equals (TagName)) { String componentname = xmlpullparser.getattributevalue (0); if (COMPonentname.startswith ("OMX.")) {if (!componentname.startswith ("Omx.google.")) {Ishardcode = true; }}}} EventType = Xmlpullparser.next (); }} catch (Exception e) {//Todo:handle Exception}} return ishardcode;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Fourth chapter-android platform Mediacodec" to determine whether to support hard decoding code