也许以下的引用和链接可以帮助你编写自己的解决方案:
1.- 要获取可用网络提供商列表(全文引用自
如何获取可用网络提供商列表?):
“由于Android是开源的,我查看了源代码,最终找到了一个名为INetworkQueryService的东西。我猜你可以像android设置实现一样与这个服务交互。通过NetworkSettings.java提供一些指导:”
- 在onCreate中启动NetworkQueryService并进行绑定。
- loadNetworksList()方法告诉服务查询网络运营商。
- 对INetworkQueryServiceCallback进行评估,如果引发了“EVENT_NETWORK_SCAN_COMPLETED”事件,则会调用networksListLoaded方法以遍历可用网络。
2.- 即使快速阅读
NetworkSetting.java 和
INetworkQueryService interface,也能给我们一个实现你目标的想法。
private INetworkQueryService mNetworkQueryService = null;
private final ServiceConnection mNetworkQueryServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
if (DBG) log("connection created, binding local service.");
mNetworkQueryService = ((NetworkQueryService.LocalBinder) service).getService();
loadNetworksList();
}
public void onServiceDisconnected(ComponentName className) {
if (DBG) log("connection disconnected, cleaning local binding.");
mNetworkQueryService = null;
}
};
onCreate启动NetworkQueryService并将其绑定。
Intent intent = new Intent(this, NetworkQueryService.class);
...
startService (intent);
bindService (new Intent(this, NetworkQueryService.class), mNetworkQueryServiceConnection,
Context.BIND_AUTO_CREATE);
- loadNetworksList() 告诉服务查询网络运营商。
private void loadNetworksList() {
...
try {
mNetworkQueryService.startNetworkQuery(mCallback);
} catch (RemoteException e) {
}
displayEmptyNetworkList(false);
}
- 评估 INetworkQueryServiceCallback:
private final INetworkQueryServiceCallback mCallback = new INetworkQueryServiceCallback.Stub() {
public void onQueryComplete(List<OperatorInfo> networkInfoArray, int status) {
if (DBG) log("notifying message loop of query completion.");
Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_COMPLETED,
status, 0, networkInfoArray);
msg.sendToTarget();
}
};
如果事件“EVENT_NETWORK_SCAN_COMPLETED”被触发,将调用networksListLoaded来迭代可用的网络。
- The program uses a recursive algorithm to traverse the directory structure and find all the files that match the specified extension.
该程序使用递归算法遍历目录结构并查找与指定扩展名匹配的所有文件。
- The user can customize the font size and color of the text in the settings menu.
用户可以在设置菜单中自定义文本的字体大小和颜色。
- To add a new item to the list, click on the "Add Item" button and fill out the required fields in the form.
要向列表中添加新项目,请单击“添加项目”按钮并填写表格中的必填字段。
- The application supports multiple languages including English, French, and Spanish.
该应用程序支持多种语言,包括英语、法语和西班牙语。
private void networksListLoaded(List<OperatorInfo> result, int status) {
...
if (status != NetworkQueryService.QUERY_OK) {
...
displayNetworkQueryFailed(status);
displayEmptyNetworkList(true);
} else {
if (result != null){
displayEmptyNetworkList(false);
...
} else {
displayEmptyNetworkList(true);
}
}
}
我希望这有所帮助。我觉得这是一个有趣的挑战,也许下次我有空会试试。祝你好运!