By Elizabeth Koh

SEOUL -- Samsung Electronics Co. reported a boost in its second-quarter net profits Thursday, aided by a one-time gain in its display business and the continuing coronavirus-fueled bump in memory chip demand.

But the world's largest smartphone and memory-chip maker is likely to face challenges, as the realities of the Covid-19 pandemic settle in. Large cloud computing companies that stockpiled chips so far may dial down their buying, while smartphone demand recovery may be slow in the near future.

Samsung is a proxy for the global economy, both as a manufacturer of smartphones, televisions and home appliances and as a parts supplier to the world's largest electronics firms.

The firm's unexpected success in the first half of the year showed how the tech industry could profit from a surge in internet demand, as more workers clocked in from home. Demand for online services and data-server suppliers -- which include Samsung's memory chips -- soared. But the pullback in global discretionary spending, resulting from job losses to pandemic lockdowns, has harmed Samsung's sales of smartphones and other consumer electronics.

Samsung's second-quarter net profits rose to 5.56 trillion South Korean won ($4.67 billion) in the quarter ending June 30, versus 5.18 trillion won for the prior year's quarter. Operating profits rose to 8.15 trillion South Korean won ($6.8 billion) over 6.6 trillion won a year before. Revenue dipped about 6% to 52.97 trillion won ($44.4 billion) from 56.13 trillion won during the same period a year ago. Analysts had projected a slight decline in revenue but a rise in profits after the company's earnings guidance earlier this month.

Much of the positive performance in the second quarter was driven by peaking demand from data centers, which ramped up as employees hollowed out offices to work from home and socialize remotely.

But many of those buyers, who feared supply-chain disruptions early on, built up inventories of memory chips that will now carry them through the second half of the year, said S.K. Kim, an analyst at Daiwa Securities.

Samsung's display business also got a profit bump from Apple Inc., thanks to a penalty payment baked into a deal between the smartphone rivals, analysts said. Samsung is the main supplier for the premium flexible OLED screens used in Apple's newer iPhones.

Typical industry contracts require a penalty payment to the component supplier, if a client purchases fewer units than required, especially in capital-heavy manufacturing. This year's payment, estimated to be around $900 million to $950 million, would be the largest payment by Apple to Samsung since the Cupertino, Calif.,-based company signed an OLED deal with its South Korean counterpart in 2016, analysts said.

Samsung is overwhelmingly the No. 1 player for these particular displays, prized because the glass can be curved to give users a bigger screen or a sleeker design. But the Apple payment is less a windfall than a cushion for the major investment Samsung has already made in building up its OLED manufacturing, said Bob O'Brien, co-founder of Display Supply Chain Consultants.

For now, Samsung appears to have overshot demand, as the OLED screens -- generally the priciest component in a premium handset -- haven't been adopted by other smartphone makers outside of Apple and Samsung, Mr. O'Brien added. "Samsung built more capacity than they needed," he said. "This payment from Apple is sort of like insurance -- you only collect insurance when something bad happens."

Lowered consumer demand for handsets -- Samsung's other main profit driver -- have also weakened the company's performance. As it prepares to debut new models in its flagship Galaxy Note line next week, the company is still trying to move excess inventory of its main Galaxy S20 devices, said Mehdi Hosseini, an analyst with Susquehanna International Group. The Galaxy S20 hit shelves in March, as the coronavirus pandemic shut down retailers and crimped consumer purchasing.

The company is leaning on affordable options like its midprice 5G-enabled options like the Galaxy A71 in the U.S. and other markets to boost volume. Samsung is also expected to price its Galaxy Note phones much more competitively and potentially trim the price tags on its Galaxy S20 devices to recoup some losses.

Worldwide smartphone shipments sank by nearly 20% in the first quarter of the year compared with the year prior, according to industry research firm Strategy Analytics. Samsung's phone shipments sank by more than 18% to 58.3 million devices during that period, the firm said.

But retail sales are picking up again globally, as lockdowns are eased, even though coronavirus cases still continue to tick upward, especially in the United States.

Write to Elizabeth Koh at Elizabeth.Koh@wsj.com