I get the following error
"Are you missing a call to unregister receiver"
when I hit the back button to exit my application. How do I identify which Receiver is causing the leak and eliminate the error? I am using the code "DownLoader" from Google to download an expansion file.
10-27 22:13:32.818: E/ActivityThread(30744): Activity com.ssowens.groovebasstrial.BassActivity has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@41d166d0 that was originally registered here. Are you missing a call to unregisterReceiver()?
10-27 22:13:32.818: E/ActivityThread(30744): android.app.IntentReceiverLeaked: Activity com.ssowens.groovebasstrial.BassActivity has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@41d166d0 that was originally registered here. Are you missing a call to unregisterReceiver()?
10-27 22:13:32.818: E/ActivityThread(30744): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:800)
10-27 22:13:32.818: E/ActivityThread(30744): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:601)
10-27 22:13:32.818: E/ActivityThread(30744): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1650)
10-27 22:13:32.818: E/ActivityThread(30744): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1630)
10-27 22:13:32.818: E/ActivityThread(30744): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1624)
10-27 22:13:32.818: E/ActivityThread(30744): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:430)
10-27 22:13:32.818: E/ActivityThread(30744): at com.immersion.android.haptics.HapticFeedbackManager.setupPackageBroadcastReceiver(HapticFeedbackManager.java:564)
10-27 22:13:32.818: E/ActivityThread(30744): at com.immersion.android.haptics.HapticFeedbackManager.<init>(HapticFeedbackManager.java:108)
10-27 22:13:32.818: E/ActivityThread(30744): at com.immersion.android.HapticFeedbackManagerProxy.initialize(HapticFeedbackManagerProxy.java:90)
10-27 22:13:32.818: E/ActivityThread(30744): at com.immersion.android.HapticFeedbackManagerProxy.access$100(HapticFeedbackManagerProxy.java:30)
10-27 22:13:32.818: E/ActivityThread(30744): at com.immersion.android.HapticFeedbackManagerProxy$1$1.run(HapticFeedbackManagerProxy.java:71)
10-27 22:13:32.818: E/ActivityThread(30744): at java.lang.Thread.run(Thread.java:856)
Here is a work around !! I have a Samsung tab 7" 4.2.2
Causes of problem:
1. 4.2.2
2. ListView defined in a Layout.xml
3. new ListView(this)
Fix:
1. do not declare a ListView in the Layout, instead declare a holder
2. use 'getApplication()' instead of 'this' 'new ListView(getApplication());'
3. addView(yourListView)
TheLayoutFile.xml
The ListView in your Activity
Solution 1.
If You have a ListView with a ItemClickListener You have to set the listener to null on overrive Method onPause.
listView.setOnItemClickListener(exampleListener);
Example: Declaration of your listener
Solution 2 If You know what is your broadcastReceiver instance You have to unregister always un overrive method onPause.
@Override protected void onPause() {
The second solution I know it does not work for you but I let it for reference.
I hope it helps You.
The answer is in the LogCat you posted.
You registered a
HapticFeedbackBroadcastReceiver
inBassActivity
, which needs to be unregistered when you pause or close the app. As @svenoaks says, you should overrideActivity.onPause()
and unregister every receiver you've registered, usingunregisterReceiver(referenceToReceiver);
You must call unregisterReceiver() on any receivers you have registered in your Activity. This will typically be in onPause().