Toggling device state nearly working

NPE on Device Manager