0

I went through a lot of stuff when getting into services. So i have a remote service which connects to a server and has to send and receive incoming messages and i used a remote service to do this because i need it to run almost all the time and also make notifications. I used Messenger to communicate between the activity and service which uses the IBinder object to pass the messenger.I want to call a function from the activity in OnServiceConnected(); to connect to the server but i cannot call functions in the service from the activity as in the Service Documentation the way to call functions is through the IBinder but it is already used by the messenger.So is there a way to call a function from the activity without changing the Messenger part so what should i do? And If u don't understand what i just said feel free to ask.

Arnav Jain
  • 61
  • 9

1 Answers1

0

I found a workaround so what i did was. I connected to the server by calling the Connect()function which i had from the service's onCreate() method so i connected on creation and when in need to send a message to the server, from the activity i used Messenger to send a string to the service to call the sendMessage() method. This Server is a socket server in case anyone was thinking

Arnav Jain
  • 61
  • 9