Reputation: 1671
I need to implement code that logs whenever the current cell of the mobile network changes. It cannot run as a (background) service and it cannot routinely do checks for a changed cell id. What I need is a intent filter that fires up every time the current cell changes.
Is this possible? I tried to do this using intent filters listening for
PhoneStateListener.LISTEN_CELL_INFO
but I get nothing, even though I have set the proper permissions...
Am I doing sth wrong?
Upvotes: 3
Views: 539
Reputation: 934
You can use the PhoneStateListener to listen to cell location change.
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_CELL_LOCATION);
It requires android permission,
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
private PhoneStateListener mPhoneStateListener = new PhoneStateListener()
{
@Override
public void onCellLocationChanged(CellLocation location) {
Log.d("PhoneStateListener", "Cell Location changed");
}
};
Upvotes: 0