The actor became involved with Retrak, an organisation which assists children on the streets with contacting their families, while filming scenes for The Last King of Scotland in the African country.
Speaking to Live With Regis and Kelly, the X-Men: First Class star said that he took part in a jump from the roof of Guy's Hospital in London as a way of raising the profile of the charity's work.
"It's just really a publicity stunt, to try to make people more aware of Retrak. And they made me jump off a building," he said.
"So I went face-first down from the tallest hospital in the world. It was terrifying but it was kind of fun. It was a good way to try and raise money for charity."
Last week, McAvoy admitted that he rarely gets noticed on the street, despite starring in a number of high-profile roles.
He also spoke out about the UK film industry, claiming that producers dumb down films for a US audience but fail to hit the mark either side of the Atlantic.
Watch James McAvoy on Live With Regis and Kelly below: