我有多项活动和一项服务。在MainActivity
我成功地连接到服务(使用实现类ServiceConnection
+ bindService()
+ startService()
),但是当我尝试应用在其他活动同样的方法我在logcat中看到一个错误:如何在多个活动之间保持连接到Android服务?
01-15 22:29:37.438: ERROR/ActivityThread(12206): android.app.ServiceConnectionLeaked:
Activity com.app.liviu.simpleMusicPlayer.PlaylistActivity has leaked ServiceConnection
com.app.li[email protected]43713c90
that was originally bound here.
是否有可能连接到以其他方式提供服务:类似于使0123.中的静态我的CounterServiceConnection
对象在第二个对象中使用?
这是说的错误是什么,而不是如何解决这个问题 – Will 2010-01-16 10:00:51
我在同一个活动 – Blundell 2011-04-15 18:08:53
我打电话unbindService再次调用bindService,然后bindService得到这个错误信息(这)onDestroy。要结合我打电话'布尔bindResult = bindService(新的意向书(\t \t \t \t \t Consts.MARKET_BILLING_SERVICE_ACTION),为此,// ServiceConnection。 \t \t \t \t \t Context.BIND_AUTO_CREATE)'。我可能做错了什么? – Siddharth 2012-09-05 09:27:22