Following another week of dust-ups between the media and President Trump, his predecessor shared a bit of wisdom Saturday from the other side of the world about tolerance and taking the daily news cycle in stride.

“I wasn’t worried about what was in the newspapers today,” former president Barack Obama said during a nostalgic visit to Indonesia’s capital, his childhood home. “What I was worried about was, ‘What are they going to write about me 20 years from now when I look back?’ ”

Obama was greeted by a crowd of thousands, including leaders, students and businesspeople, in Jakarta, where he opened the Fourth Congress of Indonesian Diaspora.

He reminisced about moving to Jakarta in 1967 when he was just 6 years old, shouting, “Indonesia bagian dari diri saya!” or “Indonesia is part of me!”

Obama lived in the country with his mother, an anthropologist, and his Indonesian stepfather. The couple split up after his half sister was born, and Obama moved back to Hawaii when he was 10 to live with his grandparents.

The image of former U.S. President Barack Obama is shown on a large screen at a busy street in Bogor, West Java, Indonesia, Friday. (Dita Alangkara/AP)

“My time here made me cherish respect for people’s differences,” he said, noting how he and his family had just visited two of the most treasured ancient temples — Borobudur, a Buddhist complex, and the Hindu compound of Prambanan — in the world’s most populous Muslim country.

Obama’s speech came on the final leg of his 10-day vacation in Indonesia. In addition to visiting the temples in the city of Yogyakarta on the island of Java, he and his wife, Michelle, and daughters Sasha and Malia, also went rafting and toured the resort island of Bali. On Friday, he met Indonesian President Joko Widodo at the grand Bogor Palace in West Java, just outside Jakarta.

Obama largely stayed away from U.S. politics and the Trump administration, but he did tout one of his accomplishments while in office.

“In Paris, we came together around the most ambitious agreement in history about climate change, an agreement that even with the temporary absence of American leadership, can still give our children a fighting chance,” he said.

Trump shocked many countries last month by announcing he was pulling out of the accord. He has also had a difficult relationship with members of the news media and was recently condemned by Democrats and Republicans for a tweet that attacked a female MSNBC host.

Obama stressed the importance of stepping away from news sites where only like-minded views are shared, and he warned about social media giving rise to resentment of minorities and bad treatment of people.

He urged the country to be a light of democracy and to never stop embracing differences. Indonesia has faced a rise in Islamist radicalism and anti-gay attacks and was recently condemned by rights groups for jailing Jakarta’s former governor, an ethnic Chinese Christian, for blasphemy.

“The spirit of this country has to be one of tolerance. It’s enshrined in Indonesia’s constitution, it’s symbolized by mosques and temples and churches beside each other,” Obama said. “That spirit is one of the defining things about Indonesia. It is one of the most important characteristics to set as an example for other Muslim countries around the world.”

— Associated Press