Android Phonegap: fixed NPE crash if registering or unregistering twice