Updated

Following another week of dust-ups between the media and President Donald Trump, his predecessor shared a bit of wisdom 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 Saturday 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 has 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 press 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 warned about social media giving rise to resentment of minorities and bad treatment of people.

The former president was greeted by a crowd of thousands, including leaders, students and businesspeople, in Jakarta, where he opened the Fourth Congress of Indonesian Diaspora. He is wildly popular in Indonesia, where many view him as an adopted son. A statue of the boy still remembered as "Barry" stands outside his old elementary school.

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 said he had been gorging on the local food since arriving.

"If the rainy season came, the floods were coming and we had to clean out the floors in our house and then chase the chickens because they had gone someplace else," he said to roaring laughter. "Today, Jakarta is a thriving center of commerce marked by highways and high-rises. So much has changed, so much progress has been made."

Obama lived in the country with his mother, an anthropologist, and his Indonesian stepfather. The couple split up after having his half-sister, and Obama moved back to Hawaii when he was 10 to live with his grandparents. But he said he has never forgotten the years he spent in Indonesia.

"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 "Jokowi" Widodo at the grand Bogor Palace in West Java, just outside Jakarta.

The Indonesian visit marked Obama's first trip to Asia since leaving office. He urged the country to be a light of democracy and to never stop embracing differences. Indonesia has faced a rise in Islamic 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."