I'm new to using Services in Android I followed a tutorial, but the
service doesn't seem to be starting.
the problem I'm having is that the onServiceConnected method never
fires so mpInterface never gets assigned.
However, I can't seem to figure out why I've looked at several
examples and they all seem to be doing exactly what I am. What am I
missing?
INFO:
I'm using SDK v1.5
I'm using Eclipse which finds no errors
showAlert is a simple message box function I use for debugging in the
application
The application basically just needs to play audio files, but needs to
keep playing even if the user is doing other things on their phone (if
there is another way to achieve this I'm all ears)
CODE:
AndroidManifest.xml:
<service android:name=".NSService" />
NSPlayer.java:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
conn = new CounterServiceConnection();
this.bindService(new Intent(NSPlayer.this,NSService.class),
conn, Context.BIND_AUTO_CREATE);
......
private NSSInterface mpInterface;
private CounterServiceConnection conn;
class CounterServiceConnection implements ServiceConnection {
public void onServiceConnected(ComponentName name, IBinder
service) {
// TODO Auto-generated method stub
mpInterface = NSSInterface.Stub.asInterface((IBinder)service);
showAlert("Just so you know","mpInterface was
bound","Ooook!");
}
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
mpInterface = null;
showAlert("Just so you know","mpInterface was
UNbound","Ooook!");
}
};
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---