Gray's mother, speaking to Judge Morris, said if her son was on bail, it would be a lot easier for him to receive treatment.
However, the defence and Gray were unsure exactly when the programme would start.
Police prosecutor Garry Wilson said Gray should remain in custody until he began the treatment programme.
Judge Morris said it was clear there was a drug problem and Gray was taking steps to address his addiction with the support of his family.
"You are heading along the right track," the judge said. "You accepted there is an underlying addiction. It does demonstrate to the community and the court you are accepting responsibility."
She remanded him on bail to his mother's address and ordered him to undertake the treatment programme, not consume alcohol or non-prescription drugs and undergo random drug screening.
Gray, and his mother, were visibly relieved.
He will appear in court again in March.
He faces a maximum of three months in prison and a fine of $4500.