广播意图的蓝牙,WIFI和振铃模式蓝牙、振铃、意图、模式

2023-09-05 07:48:07 作者:╰愚愚蠢的自己,何时才清醒

什么是被广播以下事件的意图,

在无线状态变化 在蓝牙状态变化 在振铃模式的变化 解决方案

有关无线状态的变化:

WifiManager.WIFI_STATE_CHANGED_ACTION (android.net.wifi.WIFI_STATE_CHANGED)

  

广播意图的行动表明   该无线网络已经启用,禁用,   启用,禁用,还是个未知数。一   额外提供这种状态为int。   另额外提供了previous   状态,如果有的话。

WifiManager.NETWORK_STATE_CHANGED_ACTION(android.net.wifi.STATE_CHANGE)

  

广播意图的行动表明   这对Wi-Fi连接的状态   已经改变。一个额外提供   在的NetworkInfo的形式,新的国家   目的。如果新的状态连接,   第二个额外的可提供BSSID   的接入点,为一个字符串。

WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION(android.net.wifi.supplicant.CONNECTION_CHANGE)

  

广播意图的行动表明   这给请求者的连接   已经建立(现在它是   可以进行无线网络连接的操作)   或连接到请求者   已丢失。一个额外提供   连接状态作为一个boolean值,其中   真正进行连接。

另外看看ConnectivityManager.CONNECTIVITY_ACTION(android.net.conn.CONNECTIVITY_CHANGE)

  

在网络连通性的变化有   发生了。一个连接或者已被   建立或丢失。该的NetworkInfo   为受影响的网络被发送作为   额外;应该咨询看   什么样的连通性事件   发生了。

     网络时间协议可独立地估算计算机时钟偏差

如果这是一个连接是这样的   从一个失败过的结果   断开网络,再   FAILOVER_CONNECTION布尔多是   设置为true。

     

有关一个连接丢失,如果   连接管理器正在试图   连接(或已连接)到   另一网络时,所述的NetworkInfo为   新的网络也通过为   额外。这使的任何接收器   广播知道,他们不应该   一定告诉用户没有任何数据   流量将成为可能。取而代之的是,   reciever应该期​​待着另一个   广播很快,既表明   故障切换尝试成功(等   还有总体数据   连接),或故障转移   尝试失败,这意味着所有   连接已丢失。

     

有关断开事件,布尔   额外EXTRA_NO_CONNECTIVITY设置为   真如果没有连接   网络都没有。

有关蓝牙状态的变化:

BluetoothAdapter.ACTION_STATE_CHANGED (android.bluetooth.adapter.action.STATE_CHANGED)

  

广播事件:的状态   本地蓝牙适配器已经   改变。   例如,蓝牙已经接通   打开或关闭。

和振铃模式的变化:

AudioManager.RINGER_MODE_CHANGED_ACTION(android.media.RINGER_MODE_CHANGED)

  

持久广播意图的行动   指示振铃模式具有   改变。包括新的振铃模式。

不是振铃模式的变化,但是这可以很好的也有AudioManager.VIBRATE_SETTING_CHANGED_ACTION(android.media.VIBRATE_SETTING_CHANGED)

  

广播意图的行动表明   该振动的设置已经改变。   包括振动类型及其新   设置。

(行动,没有得到代表所以只有2链接... :()

What are the intents that are broadcasted in the following events,

Wifi state change Bluetooth state change Ringer mode change

解决方案

For Wifi state changes:

WifiManager.WIFI_STATE_CHANGED_ACTION ("android.net.wifi.WIFI_STATE_CHANGED")

Broadcast intent action indicating that Wi-Fi has been enabled, disabled, enabling, disabling, or unknown. One extra provides this state as an int. Another extra provides the previous state, if available.

WifiManager.NETWORK_STATE_CHANGED_ACTION ("android.net.wifi.STATE_CHANGE")

Broadcast intent action indicating that the state of Wi-Fi connectivity has changed. One extra provides the new state in the form of a NetworkInfo object. If the new state is CONNECTED, a second extra may provide the BSSID of the access point, as a String.

WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION ("android.net.wifi.supplicant.CONNECTION_CHANGE")

Broadcast intent action indicating that a connection to the supplicant has been established (and it is now possible to perform Wi-Fi operations) or the connection to the supplicant has been lost. One extra provides the connection state as a boolean, where true means CONNECTED.

Also take a look at ConnectivityManager.CONNECTIVITY_ACTION ("android.net.conn.CONNECTIVITY_CHANGE")

A change in network connectivity has occurred. A connection has either been established or lost. The NetworkInfo for the affected network is sent as an extra; it should be consulted to see what kind of connectivity event occurred.

If this is a connection that was the result of failing over from a disconnected network, then the FAILOVER_CONNECTION boolean extra is set to true.

For a loss of connectivity, if the connectivity manager is attempting to connect (or has already connected) to another network, the NetworkInfo for the new network is also passed as an extra. This lets any receivers of the broadcast know that they should not necessarily tell the user that no data traffic will be possible. Instead, the reciever should expect another broadcast soon, indicating either that the failover attempt succeeded (and so there is still overall data connectivity), or that the failover attempt failed, meaning that all connectivity has been lost.

For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY is set to true if there are no connected networks at all.

For Bluetooth state changes:

BluetoothAdapter.ACTION_STATE_CHANGED ("android.bluetooth.adapter.action.STATE_CHANGED")

Broadcast Action: The state of the local Bluetooth adapter has been changed. For example, Bluetooth has been turned on or off.

and for Ringer mode changes:

AudioManager.RINGER_MODE_CHANGED_ACTION ("android.media.RINGER_MODE_CHANGED")

Sticky broadcast intent action indicating that the ringer mode has changed. Includes the new ringer mode.

Not a ringer mode change, but this can be good to have also AudioManager.VIBRATE_SETTING_CHANGED_ACTION ("android.media.VIBRATE_SETTING_CHANGED")

Broadcast intent action indicating that the vibrate setting has changed. Includes the vibrate type and its new setting.

(Ops, got no rep so only 2 links... :( )

 
精彩推荐