President Barack Obama criticized the Black Lives Matter movement, saying that activists should be willing to sit down and discuss their agenda with leaders in power rather than “yelling at them.”

At a youth town hall in London on Saturday, the president lauded the movement for effectively bringing attention to racially motivated police violence across the country, but he said the harsh tone activists are using is troubling.

“You can’t just keep on yelling at them and you can’t refuse to meet because that might compromise the purity of your position,” Obama said. “The value of social movements and activism is to get you at the table, get you in the room and then start trying to figure out how is this problem going to be solved. You then have a responsibility to prepare an agenda that is achievable —that can institutionalize the changes you seek and to engage the other side.”

RELATED: The complex history of the controversial 1994 crime bill

Obama’s remarks come weeks after activists from the movement protested at presidential candidates’ campaign events, including Hillary Clinton —the Democratic Party’s front-runner.

In Philadelphia earlier this month, when former President Bill Clinton was campaigning for his wife, Hillary, he engaged in a heated back and forth exchange with activists who slammed him for the 1994 crime bill he enacted.

The Clintons have faced intense scrutiny from Black Lives Matter activists and other protesters over the law, which they say unfairly put a high number of black and Latino Americans in prisons and allocated billions of dollars for prison grants and police expansion.

And at a South Carolina private fundraiser in February, an activist from the group interrupted the event, calling out Clinton for the “super predators” term she had used to advocate for the 1994 measure as first Lady. Some say the racially-charged term targets young people of color. Clinton had recently said he regrets using the term.

At the London youth forum, president Obama called on activists to compromise with those they disagree with.

“Too often what I see is wonderful activism that highlights a problem, but then people feel so passionately and are invested in the purity of their position that they never take that next step and say, ‘well now I have to sit down and try to actually get something done ?’” he said.