android widget and localservice bind

混江龙づ霸主 提交于 2019-12-08 01:32:35

问题


I writing player, it has main activity that runs localservice. I can't find how bind localservice to widget. When i trying to bind it like in activity it fails.

Plz help me.

Adding #1 How can I contact with background service when? http://www.developer.com/ws/data/article.php/10944_3843561_1/Handling-Lengthy-Operations-with-Android-App-Widgets.htm

here i found something, but it doen't work for me.


回答1:


You cannot bind to a service from an AppWidgetProvider.




回答2:


You can bind to a service from a AppWidgetProvider like so:

context.getApplicationContext().bindService(intent, ServiceConnection, Flags);

The context is the parameter on the onUpdate method.



来源:https://stackoverflow.com/questions/3797201/android-widget-and-localservice-bind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!