Android bindservice failure resolution

Android bindservice failure resolution

Phenomenon:

The same code has been used normally in the past, but it has failed to bind recently in the project. Bindservice returns false.

reason:

Tabactivity is used. The child activity in tabactivity calls this.bindservice, resulting in failure. This problem belongs to the defect of Google Android. Since the tabacity has been abandoned, it has not been fixed.

resolvent:

Only when getapplicationcontext() is used to obtain the context environment of the activity to which it belongs can bingservice normally.

The correct code is as follows:

The above is the solution to the failure of Android bindservice. If you have any questions, please leave a message or go to the community of this site for communication and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>