关于Android打开/关闭飞行模式的一些思考
2012-08-24 09:10
573 查看
我们都知道,目前在Android上编码实现打开或关闭飞行模式,都是直接调用android.provider.Setting.System.putString()接口实现的,代码如下:
......
// Enable airplane mode
Settings.System.putString(cr,Settings.System.AIRPLANE_MODE_ON, "1");
Intent intent =
new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
sendBroadcast(intent);
// Disable airplane mode
Settings.System.putString(cr,Settings.System.AIRPLANE_MODE_ON, "0");
Intent intent =
new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
sendBroadcast(intent);
......
为什么Android不能把这个接口直接放在ConnectivityManager里呢,其实打开飞行模式就是要关闭所有数据连接(包括把modem设置成airplane mode)。如果放在ConnectivityManager里,不是更方便开发人员调用吗?
......
// Enable airplane mode
Settings.System.putString(cr,Settings.System.AIRPLANE_MODE_ON, "1");
Intent intent =
new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
sendBroadcast(intent);
// Disable airplane mode
Settings.System.putString(cr,Settings.System.AIRPLANE_MODE_ON, "0");
Intent intent =
new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
sendBroadcast(intent);
......
为什么Android不能把这个接口直接放在ConnectivityManager里呢,其实打开飞行模式就是要关闭所有数据连接(包括把modem设置成airplane mode)。如果放在ConnectivityManager里,不是更方便开发人员调用吗?
相关文章推荐
- Android 飞行模式的设置(打开/关闭飞行模式,获取飞行状态状态)
- Android 飞行模式的设置(打开/关闭飞行模式,获取飞行状态状态)
- (转)关于Android MVP模式的思考
- Android关于OutOfMemoryError的一些思考
- [体感游戏]关于体感游戏的一些思考(六)--- 飞行
- 关于Android Log的一些思考
- 关于屏蔽Android返回键的一些思考
- 关于Android中ANR的一些思考
- Android关于OutOfMemoryError的一些思考
- Android开发中关于获取当前Activity的一些思考
- Android代码实现飞行模式的打开
- Android基于配置文件的测试模式(不修改代码通过配置文件来打开和关闭测试模式)
- 关于Android MVP模式的思考
- Android利用代码开启关闭飞行模式
- [体感游戏]关于体感游戏的一些思考(六)--- 飞行
- 关于单例模式的一些思考
- 关于Android手机MTP模式连接的一些设置(win7和ubuntu下,以红米1s为例)
- 关于设计模式的一些看法与思考
- 关于Android中ANR的一些思考
- 关于android UI适配的一些思考