Wish Allow #Extends for service modules

corwin42

Expert
Licensed User
Longtime User
I'm currently trying to create a library for Android Wear watchfaces. Watchfaces in Android Wear are implemented as a service module. The Watchface Service needs to extend android.support.wearable.watchface.CanvasWatchFaceService.

My idea is to write a class that itself extends CanvasWatchFaceService and implements all needed methods for the watchface and will call some B4A Subs with raiseEvent() which will draw the watchface. In the B4A Service module I wanted to extend the class from my special service class.

Unfortunately the #Extends attribute is not supported in Service modules. So I'm stuck with my idea. Why is #Extends not supported in Services? Should be no problem if the class itself is a subclass of android.app.service.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
#Extends for services can be added. However you can also implement your library right now. You need to create the service in your library and call a known B4A service.

It will probably work better then a service that extends a different class as B4A services make all kinds of assumptions that might be broken if you extend a different class.

Check the LiveWallpaper source code an an example.
 

Attachments

  • WallpaperInternalService.zip
    2.6 KB · Views: 336

barx

Well-Known Member
Licensed User
Longtime User
I believe the same thing was done in the wearable datalayer lib for the listener service...
 

corwin42

Expert
Licensed User
Longtime User
#Extends for services can be added. However you can also implement your library right now. You need to create the service in your library and call a known B4A service.

It will probably work better then a service that extends a different class as B4A services make all kinds of assumptions that might be broken if you extend a different class.

Check the LiveWallpaper source code an an example.

The big disadvantage with this method is that you can have only one watchface service for one app so only one watchface is possible. I need to create more than one watchface in one app. I think extending service modules will allow this.
 
Top