Hi!!
I have made two different packages for API Demo sample -
RemoteService in Service app package (Service.apk)
RemoteServiceBinding in Client app package(Client.apk)
(two different apk and two different projects in eclipse)
The Service app offer services which Client app binds to and utilizes.
The Service app gets started during BOOT COMPLETE.
This model works great when I do a full source build(without eclipse).
But when I make them under Eclipse, and my Client app invokes
registerCallback method on Service app interface, the
IRemoteServiceCallback instance(interface implemented in Client app)
is received null in Service app.
I have confirmed that mCallback (object passed) is not null.
I couldn't observe any error in logs. What could be the problem?
Thanks in advance
Ash
#####################
Client app - code
#####################
private IRemoteServiceCallback mCallback = new
IRemoteServiceCallback.Stub() {
/**
* This is called by the remote service regularly to tell us
about
* new values. Note that IPC calls are dispatched through a
thread
* pool running in each process, so the code executing here
will
* NOT be running in our main thread like most other things --
so,
* to update the UI, we need to use a Handler to hop over
there.
*/
public void valueChanged(int value) {
mHandler.sendMessage(mHandler.obtainMessage(BUMP_MSG,
value, 0));
}
};
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder service) {
// This is called when the connection with the service has
been
// established, giving us the service object we can use to
// interact with the service. We are communicating with
our
// service through an IDL interface, so get a client-side
// representation of that from the raw service object.
mService = IRemoteService.Stub.asInterface(service);
mKillButton.setEnabled(true);
mCallbackText.setText("Attached.");
// We want to monitor the service for as long as we are
// connected to it.
try {
mService.registerCallback(mCallback);
} catch (RemoteException e) {
// In this case the service has crashed before we
could even
// do anything with it; we can count on soon being
// disconnected (and then reconnected if it can be
restarted)
// so there is no need to do anything here.
}
######################
Service app code
######################
private final IRemoteService.Stub mBinder = new IRemoteService.Stub()
{
public void registerCallback(IRemoteServiceCallback cb) {
if (cb != null) mCallbacks.register(cb);
}
public void unregisterCallback(IRemoteServiceCallback cb) {
if (cb != null) mCallbacks.unregister(cb);
}
};
####################
PROBLEM---------
---------------------------------
The registerCallback gets invoked on Service app code but parameter
'cb' is null
#####################
--
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