I currently have a Service and an Activity in my application.
I currently bind the Service to the activity without using AIDL as the Service and the Activity are in the same application.
This allows me to call the methods from the Service within my Activity when I require them, however it doesn't let me call the methods of the Activity from within my Service when I want to.
Can anyone comment on what would be the best way to achieve this?
I could use Intents but is there an alternative option?
I want to have tight communication between the Service and the Activity, I want to be able to call an Activity method from my Service when an event happens.
Thanks to ognian for the excellent advice.
EDIT 2:
I now have it working the way I want, however I have come across a problem.
My service gets status updates and my Activity is then supposed to react to the update sent on from the Service.
The problem is that when I start my activity I get the Dialling Status and then Connected status before the onBind is called and I get the instance of iCallDialogActivity.
The following output from the logcat might make things clearer.
06-28 10:56:48.702: DEBUG/TestPhone(3498): Status: EStatusDialling
06-28 10:56:48.751: DEBUG/TestPhone(3498): Status: EStatusConnected
06-28 10:56:49.122: DEBUG/TestPhone(3498): Status: onBind Called <-------------
06-28 10:56:49.141: DEBUG/TestPhone(3498): Status: iCallDialogActivity instance <-------------
06-28 10:56:51.641: DEBUG/TestPhone(3498): Status: EStatusDisconnecting
06-28 10:56:51.651: DEBUG/TestPhone(3498): Status: EStatusIdle
I need to be able to use my iCallDialogActivity when I get the Dialling and Connected Status notifications.
But this gives me a NullPointer Exception due to it not being created in time when my Activity starts, binding is the first thing I do in my Activities onCreate().
Is there a way to make it bind straight away?