在我Widget
我使用:小工具。活動已泄漏IntentReceiver
Intent intent = new Intent(context, ClassForWidget.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget1);
views.setOnClickPendingIntent(R.id.layout_widget1, pendingIntent);`
而且我ClassForWidget
類已經有一個BroadcastReceiver
:
BroadcastReceiver myReceiver = new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MyService.MY_ACTION);
registerReceiver(myReceiver, intentFilter);
所以,當我點擊Widget
,我有錯誤:
Activity .ClassForWidget has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
我該如何解決?謝謝。
在註銷您的接收器之前,您的活動正在死亡 – sachy