package de.apps4ics.mountainnavigation;

import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;

/**
 * Created by Vinz on 20.10.2015.
 */
public class MyPhoneStateListener extends PhoneStateListener {
    @Override
    public void onSignalStrengthsChanged(SignalStrength signalStrength) {
        super.onSignalStrengthsChanged(signalStrength);
        if(signalStrength.isGsm()){
            int asu = signalStrength.getGsmSignalStrength();
            if(asu == 99){
                MainActivity.setNetworkStrength(-1); //unknown network strength
            } else {
                MainActivity.setNetworkStrength(Math.round(asu/0.31f));
            }
        }
    }
}
