Strange error since upgrading to Android 4.2.2 - A

2019-02-08 07:34发布

问题:

I upgraded my Samsung Galaxy Tab 2 to Android 4.2.2 last night, and have since spotted some strange errors in LogCat which didn't appear before I 'upgraded'.

I was hoping that it was highlighting a hidden bug or memory leak in my application, but I can't find anything.

It seems to only occur if the activity I'm on has a Spinner, and that Spinner is expanded.

The error is as below.

Activity uk.co.xxxx.xxxx has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@41e4bac0 that was originally registered here. Are you missing a call to unregisterReceiver()?

Has anyone else seen this? do you think it's safe to ignore as it's only occurring on one of my devices?

--- Edit ---

And, incidentally, I'm not registering any receivers anywhere, so there's nothing to unregister.

回答1:

I have the similar problem and I've asked this question on the Haptic developer's forum and received the following reply:

The exception you see is a harmless warning and the OS will take care of freeing the resources mentioned in the exception. In other words, no need to worry or do anything about it.

If you need any other details - go here



回答2:

From the stack trace I would say your Activity (masked here) registered a HapticFeedbackBroadcastReceiver that wasn't properly released. This is typically done in the onPause() lifecycle hook so that this gets called when you pause or close the Activity.

Example code:

@Override 
protected void onPause() {

    super.onPause();
    if(broadcastReceiverInstance != null){
        unregisterReceiver(broadcastReceiverInstance);
    }
}

If you haven't registered any receivers yourself maybe the system has based on a keyboard that pops up so it could be a good idea to hide keyboards or any other element used within your app that might have haptic feedback activated. Think of custom keyboards, custom views, ... anything. To check that in more detail we would need more code.