BEIJING — President Xi Jinping was holding a military parade, and the Chinese police wanted me out.

Officer Wang Yong, a veteran of the Beijing security bureau with nervous eyes and amber teeth, came to my door one recent Saturday morning to deliver the news.

“Do you know about the National Day celebrations?” he asked.

I nodded. In early October, Mr. Xi would be the host of a grand celebration to mark the 70th anniversary of the founding of the People’s Republic of China, along the Street of Eternal Peace, near my apartment.

“You need to leave,” Officer Wang said. “Armed police will be stationed inside for four days.”

As an American journalist based in Beijing for the past four years, I am accustomed to onerous visa rules, hassles at the airport and arbitrary detentions in the countryside.

But never had the police insisted on occupying my home. I imagined a cantankerous bunch of officers spread out on the sofa, poring over books on dissident art and American politics as they smoked the night away.