Fixes #228
You must renmove the callback listeners attached with the service when you
destroy the activities.
--- a/src/com/beem/project/beem/ui/ContactList.java Wed Dec 16 20:48:57 2009 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Dec 17 13:54:55 2009 +0100
@@ -66,6 +66,7 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.preference.PreferenceManager;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -122,6 +123,8 @@
private BeemBroadcastReceiver mReceiver;
private final Map<Integer, BitmapDrawable> mIconsMap = new HashMap<Integer, BitmapDrawable>();
private LayoutInflater mInflater;
+ private ComparatorContactListByStatusAndName<Contact> mComparator = new ComparatorContactListByStatusAndName<Contact>();
+ private final BeemRosterListener mBeemRosterListener = new BeemRosterListener();
/**
* Constructor.
@@ -292,8 +295,20 @@
@Override
protected void onDestroy() {
super.onDestroy();
+ try {
+ if (mRoster != null)
+ mRoster.removeRosterListener(mBeemRosterListener);
+ } catch (RemoteException e) {
+ Log.d("ContactList", "Remode exception", e);
+ }
this.unregisterReceiver(mReceiver);
- unbindService(mServConn);
+ unbindService(mServConn);
+ mRoster = null;
+ /*
+ for (BitmapDrawable d : mIconsMap.values()) {
+ d.setCallback(null);
+ }*/
+ Log.e("CONTACTLIST", "onDestroy activity");
}
/**
@@ -305,7 +320,6 @@
* Constructor.
*/
public ComparatorContactListByName() {
-
}
/**
@@ -325,7 +339,6 @@
* Constructor.
*/
public ComparatorContactListByStatusAndName() {
-
}
/**
@@ -373,7 +386,6 @@
* Constructor.
*/
public BeemContactListOnClick() {
-
}
/**
@@ -426,7 +438,7 @@
* Sort the contact list.
*/
private void sortBeemContactList() {
- Collections.sort(mListContact, new ComparatorContactListByStatusAndName<Contact>());
+ Collections.sort(mListContact, mComparator);
}
/**
@@ -437,7 +449,6 @@
* Constructor.
*/
public BeemRosterListener() {
-
}
/**
@@ -749,7 +760,6 @@
* The service connection used to connect to the Beem service.
*/
private class BeemServiceConnection implements ServiceConnection {
- private final BeemRosterListener mBeemRosterListener = new BeemRosterListener();
/**
* Constructor.