Android的:获取通知"移动数据"网络类型的变化 [英] Android: Get notification for "Mobile data" network type changes

查看:690
本文介绍了Android的:获取通知"移动数据"网络类型的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一款Android网络实用程序工作了解你的Andr​​oid网络

Working on a Android network utility Know Your Android Network

我知道,我们可以很容易地创建我们自己的广播接收器处理网络状态的变化,检查是否N / W从无线网络切换到移动数据,

I know that we can easily handle the changes in network state by creating our own Broadcast Receiver and check whether n/w switched from WiFi to Mobile data,

但有一种方式来获得通知,当从一个网络型流动数据切换到另一个。基本上我需要知道什么时候移动数据连接从一个网络跳到类型到另,下面可以是各种网络类型:

But is there a way to get notification when "Mobile Data" switches from one network type to the other. Basically I need to know when "mobile data" connection jumps from one network type to the other, Below can be the various network types:

NETWORK_TYPE_1xRTT
NETWORK_TYPE_CDMA
NETWORK_TYPE_EDGE
NETWORK_TYPE_EVDO_0
NETWORK_TYPE_EVDO_A
NETWORK_TYPE_GPRS
NETWORK_TYPE_HSDPA
NETWORK_TYPE_HSPA
NETWORK_TYPE_HSUPA
NETWORK_TYPE_UMTS
NETWORK_TYPE_EHRPD
NETWORK_TYPE_EVDO_B
NETWORK_TYPE_HSPAP
NETWORK_TYPE_IDEN
NETWORK_TYPE_LTE

例如,我可以得到一个通知,如果从EDGE移动数据切换到LTE。

For example, can i get a notification if a mobile data switches from EDGE to LTE.

谢谢!

推荐答案

下面是广播意图动作,你可以把你的IntentFilter:

Here are the Broadcast Intent Actions you can put in your IntentFilter:

android.net.conn.BACKGROUND_DATA_SETTING_CHANGED

android.net.conn.BACKGROUND_DATA_SETTING_CHANGED

android.net.conn.CONNECTIVITY_CHANGE

android.net.conn.CONNECTIVITY_CHANGE

android.net.nsd.STATE_CHANGED

android.net.nsd.STATE_CHANGED

android.net.wifi.NETWORK_IDS_CHANGED

android.net.wifi.NETWORK_IDS_CHANGED

android.net.wifi.RSSI_CHANGED

android.net.wifi.RSSI_CHANGED

android.net.wifi.SCAN_RESULTS

android.net.wifi.SCAN_RESULTS

android.net.wifi.STATE_CHANGE

android.net.wifi.STATE_CHANGE

android.net.wifi.WIFI_STATE_CHANGED

android.net.wifi.WIFI_STATE_CHANGED

android.net.wifi.p2p.CONNECTION_STATE_CHANGE

android.net.wifi.p2p.CONNECTION_STATE_CHANGE

android.net.wifi.p2p.DISCOVERY_STATE_CHANGE

android.net.wifi.p2p.DISCOVERY_STATE_CHANGE

android.net.wifi.p2p.PEERS_CHANGED

android.net.wifi.p2p.PEERS_CHANGED

android.net.wifi.p2p.STATE_CHANGED

android.net.wifi.p2p.STATE_CHANGED

android.net.wifi.p2p.THIS_DEVICE_CHANGED

android.net.wifi.p2p.THIS_DEVICE_CHANGED

android.net.wifi.supplicant.CONNECTION_CHANGE

android.net.wifi.supplicant.CONNECTION_CHANGE

android.net.wifi.supplicant.STATE_CHANGE

android.net.wifi.supplicant.STATE_CHANGE

您可以使用这些触发你的广播接收器,并从那里你可以得到的TelephonyManager参考,并使用getNetworkType()。检查网络类型

You can use these to trigger your BroadcastReceiver and from there you can get a reference to the TelephonyManager and check the network type using getNetworkType().

这篇关于Android的:获取通知"移动数据"网络类型的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆