BANGKOK — Thailand’s army on Tuesday detained an activist who wrote on Facebook that he would wear politically charged red clothing to mark King Bhumibol Adulyadej’s cremation this week.

A lawyer for Ekachai Hongkangwan said soldiers arrested Ekachai at his Bangkok home on Tuesday morning and indicated they would detain him outside the city, in Kanchanaburi province.

Ekachai commented on Facebook last week that he would wear red on Oct. 26, the day Bhumibol will be cremated during an elaborate five-day funeral, and “do what people least expect.”

Supporters of elected governments ousted by Thailand’s military in 2006 and 2014 coups are known as “Red Shirts.”

In a subsequent Facebook post, Ekachai said that a police officer visited the massage business he runs to discourage him from disrupting the funeral, and that he told the officer he would not do anything illegal.

Ekachai previously served nearly three years in prison for violating Thailand’s draconian lese majeste law by distributing copies of an Australian documentary on the Thai royal family.

After he made the Facebook posting Friday, Ekachai became a target for Thai royalists who bombarded him with attacks on social media.

Thailand’s monarchy is protected by a strict law that mandates prison sentences of up to 15 years for insulting the king and other senior royals. It has been used with increased frequency by the military government that seized power in the 2014 coup.

Supporters of the law say the monarchy is a sacred pillar of Thai society and must be protected at all costs, but critics say the law is being used to silence dissent.