Java Question Example of #Extends in Service

Discussion in 'Libraries developers questions' started by Erel, Jan 5, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Starting from B4A v6.50 services support the #Extends attribute.

    This is useful for libraries that need to extend a service.
    The previous solution was to communicate with a B4A service with a specific name. This was more cumbersome and limited.

    The #Extends attribute allows the B4A service to directly extend the library service.

    An example of the NotificationListener library implemented with #Extends is attached.

    The Java source code:

    The B4A project is attached. Notice the manifest editor code which adds the intent filter and permission to the B4A service.

    Attached Files:

    Last edited: Mar 13, 2018
  2. PhilipBrown

    PhilipBrown Active Member Licensed User

    Thanks for this.
    Can you confirm the following description is correct please?

    Service Attributes include
    #Extends: Library
    This allows you to create a service in an app (or in a new library) that extends a library service.
  3. corwin42

    corwin42 Expert Licensed User

    See the source that Erel attached.

    It is
    #Extends: Classname

    You can implement a Service class in Java that can be used as a base of the B4A service module.

    The Watchface library is one of the first libraries which use this method.
    The advantage is that it is more flexible so one app can easily support multiple watchfaces with several Service modules.
    Erel likes this.
  4. PhilipBrown

    PhilipBrown Active Member Licensed User

    Thanks very much for this.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice