关于Android打开/关闭飞行模式的一些思考

来源:互联网 发布:我的从医感受淘宝店 编辑:程序博客网 时间:2024/05/22 13:10

我们都知道,目前在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里,不是更方便开发人员调用吗?

原创粉丝点击