I'm not sure I fully understand why your getService looks as it looks. Why not do it that way:

def getService: TestService = new TestService

The second thing I do not understand is the following line

val binder = (new TestService.TestServiceBinder).asInstanceOf[TestServiceBinder]

Why do you need asInstanceOf here?

EDIT I think you have to do it like in the android documentation. In the companion object (like you have implemented it) you can not access this.

class LocalService extends Service {
   private final val localBinder = new LocalBinder()
   class LocalBinder extends Binder {
      def getService: LocalService = LocalService.this

Related Query

More Query from same tag