Class ChatServiceBinder



  • public final class ChatServiceBinder
    extends Fragment
    Takes care of the chat service bind/unbind from the host activity that started the chat. Provides a default behaviour to attach with Activity#onStart() and detach with Activity#onStop().

    Orientation change will unbind a service from destroyed activity and then it will bind again to the recreated activity. Minimizing the chat will unbind the activity and it will be re-bound when resumed.

    All chat communications should be done between Activity#onResume() and Activity#onPause() as the service might not be connected outside of that state and the instance of chat won't be able to communicate.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void onCreate(Bundle savedInstanceState) 
      void onStart()
      Bind on start to assure that activity has service connection while visible Chat service will bounded and ready to use in Activity#onPause().
      void onStop()
      Unbinding on stop to assure we don't leak service connection to the activity after the chat has ended.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChatServiceBinder

        public ChatServiceBinder()
    • Method Detail

      • onCreate

        public void onCreate(Bundle savedInstanceState)
      • onStart

        public void onStart()
        Bind on start to assure that activity has service connection while visible

        Chat service will bounded and ready to use in Activity#onPause().

        Note: pre appcompat-v7 23.2.x chat service will be bounded even in Activity#onStart()

      • onStop

        public void onStop()
        Unbinding on stop to assure we don't leak service connection to the activity after the chat has ended.

        Chat service will unbounded after Activity#onStop(). All of the chat operations should finish before in Activity#onPause()