navinkumarbca / android-protips-location

Automatically exported from code.google.com/p/android-protips-location
0 stars 0 forks source link

IntentReceiver leak on device rotation #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. start the app
2. rotate the between landscape and portrait
3. check logcat

Expected:
- no logcat messages about leaks

Actual:

- leak indicated in logcat:
E/ActivityThread( 8110): Activity 
com.radioactiveyak.location_best_practices.UI.PlaceActivity has leaked 
IntentReceiver 
com.radioactiveyak.location_best_practices.utils.GingerbreadLastLocationFinder$1
@419b1f00 that was originally registered here. Are you missing a call to 
unregisterReceiver()?

App built from source 2012-0 with Android 3.2 API, running on 4.0.4 (Samsung 
Galaxy Note).

Original issue reported on code.google.com by dbbt...@googlemail.com on 3 Aug 2012 at 6:51

GoogleCodeExporter commented 8 years ago
*built from source 2012-08-03 (r5)

Original comment by dbbt...@googlemail.com on 3 Aug 2012 at 6:52

GoogleCodeExporter commented 8 years ago
It is because "LastLocationFinder" uses Activity's context and 
"singleUpdateReceiver" may outlive the activity, you can use "this.context = 
context.getApplicationContext();" in the constructor, but still 
"locationListener" holds the reference to the old activity, requesting single 
update in LastLocationFinder is broken, you may instead try to send broadcast 
to passive receiver 

Original comment by biegl...@gmail.com on 18 Feb 2014 at 12:34