デバイスがローミング中かどうかを確認する必要があるアンドロイドでアプリを開発しています。このコードを使用すると、
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秒ごとにトーストを印刷し続けます。セルの場所が通常のネットワークからローミングに変更された場合にのみ、トーストを印刷したいと考えています。