gpt4 book ai didi

Android连接更改广播顺序

转载 作者:行者123 更新时间:2023-11-29 17:15:36 27 4
gpt4 key购买 nike

我已经在 list 中声明了 android.net.conn.CONNECTIVITY_CHANGE,这样我就可以在用户连接发生变化时收到通知。

我收到了同一事件的多个广播。以下信息(intent.getExtras() 的打印)是在我打开移动连接和 wifi 然后打开 wifi 时检索到的。

[ networkInfo => NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "HOME", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false; networkType => 1; inetCondition => 0; extraInfo => "HOME"; ]

[ networkInfo => NetworkInfo: type: mobile[UMTS], state: DISCONNECTED/DISCONNECTED, reason: dataDisabled, extra: web.network.de, roaming: true, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false; networkType => 0; otherNetwork => NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "HOME", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false; reason => dataDisabled; inetCondition => 0; extraInfo => web.network.de; ]

[ networkInfo => NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "HOME", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false; networkType => 1; inetCondition => 0; extraInfo => "HOME"; ]

是否可以先接收断开事件然后再接收连接事件?

最佳答案

据我所知,这是不可能的。我认为这与Android在断开移动网络之前首先尝试通过WIFI连接(防止用户在连接失败时失去连接)有关。

无论如何,您始终可以保存收到的信息,然后根据需要进行处理。只需重新考虑您的方法,您可能不需要按顺序接收该信息。

关于Android连接更改广播顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39206095/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com