我有多个活动和一个服务。在 MainActivity
中,我成功地连接到了服务(使用实现了 ServiceConnection
+ bindService()
+ startService()
的类),但是当我尝试在其他活动中应用相同的方法时,在 LogCat 中看到了一个错误:
01-15 22:29:37.438: ERROR/ActivityThread(12206): android.app.ServiceConnectionLeaked:
Activity com.app.liviu.simpleMusicPlayer.PlaylistActivity has leaked ServiceConnection
com.app.liviu.simpleMusicPlayer.PlaylistActivity$CounterServiceConnection@43713c90
that was originally bound here.
是否可以以其他方式连接到服务:例如,在MainActivity
中将我的CounterServiceConnection
对象设置为静态,并在第二个对象中使用它?
boolean bindResult = bindService(new Intent(Consts.MARKET_BILLING_SERVICE_ACTION), this, Context.BIND_AUTO_CREATE)
。我可能做错了什么? - Siddharth