I'm trying to make my first service. The sample code I got has the ServiceConnection created as a inner class in the activity that creates the service.
I would like ServiceConnection to be outside the activity class that creates the service so other actites can crat the service and use the same ServiceConnection class.
So i'm trying to sublclass it so it will be created in its own file.
public class CMYServiceConnection extends ServiceConnection {
I GET ERROR HERE
Messenger mService = null;
boolean mBound;
public void onServiceConnected(ComponentName className, IBinder service) {
// This is called when the connection with the service has been
// established, giving us the object we can use to
// interact with the service. We are communicating with the
// service using a Messenger, so here we get a client-side
// representation of that from the raw IBinder object.
mService = new Messenger(service);
mBound = true;
}
public void onServiceDisconnected(ComponentName className) {
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
mService = null;
mBound = false;
}
}
ServiceConnection
is an interface, and classes can't extend interfaces.
Use implements
instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With