Skip to content

Building A Custom Service

chrisrhoden edited this page Mar 24, 2013 · 3 revisions

Subclassing PlayerHaterService

The easiest way to change some behavior of the service is to subclass PlayerHaterService and override whatever methods you need to. You should then add your custom service to the AndroidManifest.xml file.

Using the Interfaces

If you would like to implement your own service but use the existing IPlayerHaterBinder, your service should implement IPlayerHaterService. You should then return an IPlayerHaterBinder from the onBind() method in your service;

package com.example;

public class MyService extends Service implements IPlayerHaterService {

    private final IBinder mBinder = new IPlayerHaterBinder.Stub() {
        // your implementation here...
    };

    @Override
    public void onBind() {
        return 
    }

}

From Scratch

If you'd like to start from scratch, the only thing you absolutely must to to work with the PlayerHater loader class is to return an IPlayerHaterBinder.Stub from the onBind() method.

Clone this wiki locally