Hi,
I am having issue with memory after running many times my app.
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
I figure I was leaking memory somehow so I did a DUMP HPROF file and used the MAT tool to figure out what was wrong. It turns out that after running like 5 times the app and quiting, I find 5 instances of my Activity and 5 instances of PhoneStateListener.
If I remove the call to PhoneStateListener, I don't have that issue anymore and I see just 1 instance of my Activity.
The question is, how do I resolve this?
Thanks
Daniel
Here is my code:
OnCreate method:
telephonyManager.listen(mPhoneListener, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTH | PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_DATA_ACTIVITY);
on the Activity class:
PhoneStateListener mPhoneListener = new PhoneStateListener() { public void onCallStateChanged(int state, java.lang.String incomingNumber) { //do something } }
on onDestroy method:
telephonyManager.listen(mPhoneListener, PhoneStateListener.LISTEN_NONE); mPhoneListener = null;