您的位置:首页 > 移动开发 > Android开发

关于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里,不是更方便开发人员调用吗?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: