Android判断是否飞行模式已经监听飞行模式
2015-10-21 15:20
525 查看
1.判断是否飞行模式:
2.广播监听飞行模式:
private boolean isAirPlaneModeOn(){ int mode = 0; try { mode = Settings.Global.getInt(getContentResolver(), Settings.Global.AIRPLANE_MODE_ON); }catch (SettingNotFoundException e) { e.printStackTrace(); } return mode == 1;//为1的时候是飞行模式 }
2.广播监听飞行模式:
private BroadcastReceiver airplaneModeOn = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if(action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)){//飞行模式状态改变 //To Do } } }; 注册广播: IntentFilter filter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED); registerReceiver(airplaneModeOn, filter);
相关文章推荐
- Android常用组件
- android中的线程机制(二)————SocketCallBack
- AndroidAnnotations框架简单使用方法
- Android 编程下 Touch 事件的分发和消费机制
- Android 项目中执行java的main方法
- android中的线程机制(一)————Runnable
- Android odex文件反编译
- android 在一个textview中实现不同的颜色和大小
- android layout以及一些常用的android控件属性
- Android fill_parent、wrap_content和match_parent的区别
- Android的OOM
- android应用中去掉标题栏的方法
- ServiceManager远程代理的获取
- AndroidAnnotations框架配置
- android自动弹出软键盘(输入键盘)
- Android编程之图片颜色处理方法
- Android中visibility属性VISIBLE、INVISIBLE、GONE的区别
- Android_07_有序广播及最终广播接收者
- Firemonkey Android IOS 图标
- Android中RelativeLayout各个属性的含义