I am developing an app in android where i need to check that whether the device is in roaming or not. when i use this code,
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);
But it keeps on printing the toast after every 2 seconds. I want the toast to be printed only when the cell location is changed from normal network to roaming.
Declare a BroadcastReceiver:
Declare this receiver in manifest :