How to remove colliding box2d bodies in AndEngine?
===

I'm using AndEngine to create a game with box2d extension. I want to implement a condition that when two bodies collide, they should be removed or respawned. Initially I tried using

    if(sprite1.collidesWith(sprite2))
    // remove the sprites

but this doesnt seem to help because the sprites are attached to their respective bodies. I also tried using contactListener as follows:

    bodyA=getFixtureA().getBody();
    bodyB=getFixtureB().getBody();
    
and then later

    if(bodyA!=null && bodyB!=null)
    // remove the bodies

but that crashed the game. Does anybody know a better way of doing it?