LED呼吸燈控制
阿新 • • 發佈:2018-12-06
該方法前提是三方應用必須打入系統應用,並且在應用程式的AndroidManifest.xml中的manifest節點中加入android:sharedUserId="android.uid.system"這個屬性。
static String RED_LED_DEV = "/sys/class/leds/red/brightness"; static String GREEN_LED_DEV = "/sys/class/leds/green/brightness"; static String BLUE_LED_DEV = "/sys/class/leds/blue/brightness"; static void setLedStatus (String ledDev, boolean setStatusOn) { try { FileOutputStream fLed = new FileOutputStream(ledDev); fLed.write((setStatusOn ? "255" : "0").getBytes()); fLed.close(); } catch (Exception e) { e.printStackTrace(); } }