The shots were fired on Blake and Bradford avenues in East New York at about 9:30 p.m. Wednesday.
Two bullets went through a window and hit Khalil Robinson in the neck and shoulder as he watched TV in the living room.
He is expected to recover.
Police believe the apartment was not the target of the shooting.
Community leaders say children should be safe in their own homes.