Skip to content Skip to sidebar Skip to footer

PhoneStateListener Acting Weird?

The weird thing that's happening is when i listen all the three states LISTEN_CELL_INFO LISTEN_CELL_LOCATION LISTEN_SIGNAL_STRENGTHS oncellInfoChanged() and onCellLocationChang

Solution 1:

Have you tried registering to all 3 events at once with only 1 listener? Internally the mGsmCellInfoProvider may be in a Map or Set, so duplicates aren't allowed, causing the later .listen(...) call to override earlier ones.

Try this:

public void addListener() {
        teleManager = (TelephonyManager) mContext
                .getSystemService(Context.TELEPHONY_SERVICE);
        int listenMask = PhoneStateListener.LISTEN_CELL_INFO +
                         PhoneStateListener.LISTEN_CELL_LOCATION +
                         PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;
        teleManager.listen(mGsmCellInfoProvider,listenMask);
    }

Post a Comment for "PhoneStateListener Acting Weird?"