广播接收器来检测移动网络的变化 [英] Broadcast Receiver to detect change in mobile network

查看:312
本文介绍了广播接收器来检测移动网络的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方法,使我的Andr​​oid应用

I am looking for a way to make my Android app

做点什么每次有移动网络发生变化时,

即。从2G要3G,4G到WLAN等。

i.e. going from 2g to 3g, 4g to wifi etc.

所有我能找到广播接收器是在丢失或网络连接的增益执行的。

All I can find for broadcast receivers are the ones that execute on loss or gain of network connection.

推荐答案

你有看着使用的 PhoneStateListener ?在<一个href=\"http://developer.android.com/reference/android/telephony/PhoneStateListener.html#LISTEN_DATA_CONNECTION_STATE\"相对=nofollow> LISTEN_DATA_CONNECTION_STATE 和<一个href=\"http://developer.android.com/reference/android/telephony/PhoneStateListener.html#LISTEN_SERVICE_STATE\"相对=nofollow> LISTEN_SERVICE_STATE 标志看好。

Have you looked into using a PhoneStateListener? The LISTEN_DATA_CONNECTION_STATE and LISTEN_SERVICE_STATE flags look promising.

这篇关于广播接收器来检测移动网络的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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