Class LED


  • public class LED
    extends ApiBindBase
    This class provides LED related APIs.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  LED.LED_ID
      check systemProperties("ro.boot.hw_version") ,if not '01',then only support 3 kinds color:@ID_RED ,@ID_GREEN, @ID_BLUE
      static interface  LED.LED_STATUS
      LED status definition check systemProperties("ro.boot.hw_version") ,if not '01',then only support 3 kinds:@STATUS_OFF ,@STATUS_ON, @STATUS_BLINK
    • Constructor Summary

      Constructors 
      Constructor Description
      LED​(android.content.Context context)
      This constructor will not bind the service automatically.
      LED​(android.content.Context context, ServiceStatusCallback callback)
      This constructor will bind the service automatically.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void bindService()
      Bind service
      boolean controlLed​(int ledId, int status, int onMs, int offMs)
      Control LED on or off
      boolean isServiceReady()
      Check if service is ready.
      void unbindService()
      Unbind service
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LED

        public LED​(android.content.Context context)
        This constructor will not bind the service automatically. Please call bindService() at least once before using APIs.
        Parameters:
        context - better to use Context.getApplicationContext() to prevent memory leaks
        Throws:
        java.lang.IllegalArgumentException - if context is null.
      • LED

        public LED​(android.content.Context context,
                   ServiceStatusCallback callback)
        This constructor will bind the service automatically.
        Parameters:
        context - better to use Context.getApplicationContext() to prevent memory leaks
        callback - used to get the notification when service is ready.
        Throws:
        java.lang.IllegalArgumentException - if context or callback is null.
        See Also:
        ServiceStatusCallback
    • Method Detail

      • isServiceReady

        public boolean isServiceReady()
        Check if service is ready.
        Returns:
        true if ready; false otherwise.
      • controlLed

        public boolean controlLed​(int ledId,
                                  int status,
                                  int onMs,
                                  int offMs)
        Control LED on or off
        Parameters:
        ledId - , a value of LED.LED_ID e.g LED.LED_ID.ID_RED: red led, LED.LED_ID.ID_RED | LED.LED_ID.ID_GREEN this is depended on your hardware, some LEDs may not be supported.
        status - , a value of LED.LED_STATUS which you want to change to be
        onMs - , the duration of LED on
        offMs - , the duration of LED off
        Returns:
        success or failure