Hid*_*oid 6 service android broadcastreceiver intentservice
我正在使用启动IntentService的BraodCastReceiver.Everythings看起来很好用,但是我得到了这个错误,我不知道它的来源:
android.app.ServiceConnectionLeaked: Service com.merchantech.app.smartdiscount.MyIntentService has leaked ServiceConnection com.clover.sdk.v3.order.OrderConnector@535008f4 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
at android.app.ContextImpl.bindService(ContextImpl.java:1426)
at android.app.ContextImpl.bindService(ContextImpl.java:1415)
at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
at com.clover.sdk.v1.ServiceConnector.connect(ServiceConnector.java:119)
at com.clover.sdk.v1.ServiceConnector.waitForConnection(ServiceConnector.java:148)
at com.clover.sdk.v1.ServiceConnector.execute(ServiceConnector.java:209)
at com.clover.sdk.v3.order.OrderConnector.getOrder(OrderConnector.java:153)
at com.merchantech.app.smartdiscount.MyIntentService.onHandleIntent(MyIntentService.java:41)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
Run Code Online (Sandbox Code Playgroud)
这是我的BrodcastReceiver类:
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("com.test.intent.action.LINE_ITEM_ADDED")) {
Intent i = new Intent(context, MyIntentService.class);
context.startService(i);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的IntentService类:
public class MyIntentService extends IntentService {
public MyIntentService() {
super("MyIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
orderItem.addLineItem(orderId, lineItemId, var);
}
}
Run Code Online (Sandbox Code Playgroud)
错误消息基本上意味着某个组件在Service组件被销毁之前创建了绑定到a 并且没有从服务解除绑定.
您需要提供有关应用程序结构的更多信息,以便更好地回答您的问题.我会做一些猜测,也许会给你一些关于要探索的东西的想法.
我猜你正在使用Clover的库,也许还有Merchantech.或者Clover库可能使用Merchantech库.我也猜测这orderItem是Clover定义的类的实例,而不是你.
Android运行时会IntentService在onHandleIntent()完成后销毁,并且不再有排队的Intent请求.您可以通过使用Log命令将该onDestroy()方法添加到您的方法来确认这一点,MyIntentService以显示它何时被调用.这意味着在您发布的代码中onHandleIntent(),您的IntentService将在addLineItem()完成调用后很快销毁.
堆栈跟踪表明由调用触发的处理orderItem.addLineItem()导致绑定到另一个服务.在某个地方,这种绑定没有得到妥善管理 - 也许在它应该没有解除时.当您的组件(服务或活动)被销毁时,Clover子系统是否期望您"关闭"它或"释放"资源?
解决了:
该问题是由 Clover SDK 引起的。他们没有解除绑定在 com.clover.sdk.v3.order.OrderConnector 类中某处的服务。所以这个问题与上面的代码片段无关。
| 归档时间: |
|
| 查看次数: |
20478 次 |
| 最近记录: |