STOCKTON — The text messages started four days after the officer had driven the 17-year-old girl to San Joaquin County Juvenile Hall.

The then-Stockton police Officer Matthew Huff sent messages to the teenage girl, who is not being named because she is a minor, apologizing and saying he was checking up on her, according to court documents. For three days, starting Jan. 1, Huff sent messages to the girl using a cellphone application called “TextNow,” which allows the user to send and receive messages and make phone calls.

Huff is facing felony charges that include communicating with a minor for a sexual offense; distributing, sending or exhibiting harmful material to a minor; and annoying a minor, according to a criminal complaint filed by the San Joaquin County District Attorney's Office.

He is scheduled to appear in San Joaquin County Superior Court for a pretrial hearing at 8:30 a.m. Aug. 10. Huff, who made a brief court appearance on Wednesday, is out on bail.

Court records show Huff's text messages started flirtatiously but grew increasingly lewd in nature, eventually asking the teenager to send “sexy pics” and to meet him behind a house “in the middle of nowhere” for sex.

Stockton police arrested the 29-year-old former police officer on Feb. 3 on suspicion of having inappropriate contact with a minor. He was placed on paid administrative leave until June 27, when Stockton police said he was no longer employed by the department.

Police began their investigation on Jan. 10 after receiving a complaint about the inappropriate messages.

On the morning of Dec. 28, 2017, three male juveniles were pulled over in southwest Stockton while driving a stolen vehicle. According to records, a 17-year-old girl was sitting in the driver's seat of another car, which was parked north of the stolen vehicle. After the suspects were out of the stolen vehicle, the girl was allowed to leave.

Police said an investigating officer later learned the girl had taken items from the stolen vehicle and put them in the car where she had been sitting. The girl was then arrested on suspicion of theft.

Officer Huff, who responded to the scene to assist, drove the girl to juvenile hall; it is during this about 10-minute drive that the girl alleges Huff asked for her and her cousin's phone number. She gave him her TextNow phone number.

The girl told detectives she started receiving messages from Huff, who used the username James Smith, once she was out of juvenile hall.

“Officer Huff text messaged VIC (the victim) that he wished VIC was 18 years old and knew she had a boyfriend because VIC is cute,” according to a search warrant return. “VIC stopped responding.”

The teenager reported Huff to a social worker saying the messages made her feel uncomfortable and she thought it was odd for an officer to be texting her. Child Protective Services was also notified.

According to the search warrant return, a detective gained permission from the girl to use her TextNow account and to continue communicating with Huff acting on her behalf. The detective then changed the girl's password to prevent anyone else from accessing it.

The Stockton police detective — acting on the girl's behalf — began communicating with Huff on Jan. 25. She alleges Huff on multiple occasions mentioned he was attracted to the girl and wanted to meet. He also began to ask for photos and sent a photo of himself.

“I could confirm that the photograph received by James Smith was indeed Officer Matthew Huff, due to working with him,” the detective wrote in the search warrant return.

The document outlines the progression of the alleged communication as outlined below:

Huff's messages during this time included: “I can't wait to see you,” “Kisses you touching,” and “I'm going to make u beg for it and want more and more.”

At one point, Huff reportedly became suspicious of whether the girl was really the one he was messaging and said he didn't feel comfortable sending more photos.

Detectives met with the girl on Jan. 30 and she and the girl's guardian allowed police to use a photograph of the girl. The teen sent detectives a photo, which they saved.

She was also asked to place a phone call to Huff, which the girl agreed to. According to the court documents, Huff told the girl he had just finished changing in the locker room and that now that he had heard her voice he could trust that it was her.

The girl asked whether Huff was going to send more photographs, to which he replied that he would if she started sending photos. Huff told the girl that “she is probably used to little boys and he wants to be surprised by her photographs.”

On Feb. 1, Huff continued texting back and forth and asked the girl for a “sexy pic.” The detective stated that police sent the saved “selfie” provided by the girl.

Huff responded in a series of messages that included crude, graphic and profane comments and references to sexual acts and genitalia.

The following day, Huff asked for a photograph of the girl and sent a photo of his shirtless torso. According to the return, detectives sent a photo of the girl fully clothed, but when Huff said he wanted to see her with fewer clothes, police sent a photo that was found online of a woman showing her torso from under her breast to her belly button.

According to the Stockton detective, Huff responded by saying she has “massive” breasts but wanted to see her with her T-shirt off. He is also accused of sending other sexually crude text messages and a photograph showing his penis.

Authorities allege Huff said he wanted to meet the girl at 5:30 a.m. to have sex, according to the documents.

“He then questions VIC what she would do if he impregnates her,” according to the return. “Officer Huff told VIC he would support her with whatever decision she makes. Officer Huff told VIC he knew of a place in Weston Ranch where they could meet.”

Following his February arrest, three women spoke with The Record about what they described as inappropriate messages from Huff. In the separate accounts, they described meeting the officer while he was on duty and claimed he began sending them text messages soon after each of them had contact with him. One text reviewed by The Record includes a selfie of Huff in nothing but boxer briefs.

Huff, who was hired by Stockton police in December 2012, had previously been the subject of an internal affairs investigation. Stockton police described the incident as non-criminal in nature and said the case was investigated administratively and action was taken. The details of internal affairs investigations are not made public due to state law.

Contact reporter Almendra Carpizo at (209) 546-8264 or Follow her on Twitter @AlmendraCarpizo.