如果没有互联网连接,使用 url.openstream 的 android 不会抛出 IOException。为什么? [关闭]

问题描述 投票:0回答:0

我正在使用 url.openstream 请求到服务器。如果此时没有互联网连接,我希望将数据存储在数据库中,因此在 IOException 的 catch 子句中进行存储,但它不会被捕获到这里,而是挂在 url.openstream 上。 我什至等了一分钟,但它仍然没有被 IOException catch 子句捕获。

我必须怎么做才能克服这个问题?

android url timeout ioexception
© www.soinside.com 2019 - 2024. All rights reserved.