android wifi开启状态广播异常

铂金小虫 发布于 2013/08/09 12:17
阅读 530
收藏 0
我监听WifiManager.NETWORK_STATE_CHANGED_ACTION。但是奇怪的是,我进入页面后都没有操作wifi(还是原来的状态,没开启没关闭),但是BroadcastReceiver里该事件确实处罚了一次,有遇到过的吗?
receiver = new BroadcastReceiver(){
			@Override
			public void onReceive(Context arg0, Intent intent) {
				String act = intent.getAction();
				if(WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(act)){
					NetworkInfo netinfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
					State state = netinfo.getState();
					if(state==State.DISCONNECTED){
						MsgSender.sendMsg(handler,2);
					}else if(state==State.CONNECTING){
						Log.i("ssss", "dddd");
					}else if(state==State.CONNECTED){
//						MsgSender.sendMsg(handler,3);
					}
				}
			}
		};
		//广播事件过滤
		IntentFilter filter = new IntentFilter();
		filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
		registerReceiver(receiver, filter);

加载中
0
richardor
richardor
这个问题我也遇到了,你解决了吗?
返回顶部
顶部