我正在尝试检测漫游激活的发生。到目前为止,我已经使用了以下代码片段,但因为我还没有能够测试它,所以我不知道它的正确性。
TelephonyManager telephonyManager = TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener cellLocationListener = new PhoneStateListener() {
public void onCellLocationChanged(CellLocation location) {
if(telephonyManager.isNetworkRoaming()
{
Toast.makeText(getApplicationContext(),"in roaming",Toast.LENGTH_LONG).show();
}
}
};
telephonyManager.listen(cellLocationListener, PhoneStateListener.LISTEN_CELL_LOCATION);
我写了这段代码,认为漫游激活需要先更换信号单元。请告诉我我的推论是否正确,如果不是,我该如何实现它。