Home » Android » java – android onServiceConnected() is called in a separate thread?

java – android onServiceConnected() is called in a separate thread?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have been looking for a clear answer for this, but couldn’t find it anywhere. When an android app tries to make a connection with service and implements the ServiceConnection methods (onServiceConnected() and onServiceDisconnected()), do these callback functions run in a separate thread or in the main UI thread? Any idea?

How to&Answers:

These methods are called on the main thread. The documentation for ServiceConnection clearly states that:

Like many callbacks from the system, the methods on this class are
called from the main thread of your process.