How do I bind this service in Android?

前端 未结 3 728
小鲜肉
小鲜肉 2020-12-06 02:36

This is the code in my Activity. Initiate an Intent, then a Connection, right?

hello_service = new Intent(this         


        
3条回答
  •  天涯浪人
    2020-12-06 02:56

    Binding to a service from an Activity should be avoided as it causes probems when the Activity Configurations change (e.g. if the device is rotated the activity would get created again from scratch and the binding would have to be re-created).
    Please refer to the comment from Commonsware on the following post on stackoverflow
    Communicate with Activity from Service (LocalService) - Android Best Practices

提交回复
热议问题