我正在android中开发一个应用程序,我需要检查设备是否处于漫游状态。当我使用此代码时,
Handler m = new Handler();
m.postDelayed(new Runnable()
{
public void run()
{
if(telephonyManager.isNetworkRoaming())
{
Toast.makeText(getApplicationContext(), "Network is in Roaming", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(), "Network not in Roaming", Toast.LENGTH_LONG).show();
}
}
}, 2000);
但它会在每 2 秒后继续打印吐司。我希望仅当小区位置从正常网络更改为漫游时才打印吐司。