Reputation: 2874
I am implementing a Video calling application using KandySDK. I have implemented the incoming call listener in service so when my application is not visible or crashed , service can receive all incoming calls. Now, I want to pass the incoming call object ,which I received in service, to activity. I came to know that parcelable or serializable can be used in such case. I have tried to implement the parcelable mechanism but I could not succeed. So I need help from you guys. How such case can handle or how can I pass that object to activity?
I received incoming call in following method of service:
@Override
public void onIncomingCall(IKandyIncomingCall iKandyIncomingCall) {
Display.log(TAG, "Hey there! Incoming call arrived");
Intent intent = new Intent(this, CallAcceptActivity.class);
//intent.putExtra("fromService",Boolean.TRUE);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
Upvotes: 1
Views: 219
Reputation: 1007296
Have your service raise an event on an event bus (LocalBroadcastManager
, greenrobot's EventBus, Square's Otto, etc.) containing the call. Have your activity register for that event and process it when it arrives. Have your service detect the case when the event is not handled (e.g., you do not have a running activity) and do something as a fallback measure.
Here are sample apps that demonstrate this pattern for:
Upvotes: 1