Search in sources :

Example 1 with PhoneState

use of net.wigle.wigleandroid.listener.PhoneState in project wigle-wifi-wardriving by wiglenet.

the class MainActivity method setupSound.

private void setupSound() {
    // could have been retained
    if (state.soundPop == null) {
        state.soundPop = createMediaPlayer(R.raw.pop);
    }
    if (state.soundNewPop == null) {
        state.soundNewPop = createMediaPlayer(R.raw.newpop);
    }
    // make volume change "media"
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    try {
        if (TTS.hasTTS()) {
            // don't reuse an old one, has to be on *this* context
            if (state.tts != null) {
                state.tts.shutdown();
            }
            // this has to have the parent activity, for whatever wacky reasons
            state.tts = new TTS(this);
        }
    } catch (Exception ex) {
        error("exception setting TTS: " + ex, ex);
    }
    TelephonyManager tele = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    if (tele != null && state.phoneState == null) {
        state.phoneState = new PhoneState();
        final int signal_strengths = 256;
        try {
            tele.listen(state.phoneState, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | signal_strengths);
        } catch (SecurityException ex) {
            info("cannot get call state, will play audio over any telephone calls: " + ex);
        }
    }
}
Also used : PhoneState(net.wigle.wigleandroid.listener.PhoneState) TelephonyManager(android.telephony.TelephonyManager) IOException(java.io.IOException) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 TelephonyManager (android.telephony.TelephonyManager)1 IOException (java.io.IOException)1 PhoneState (net.wigle.wigleandroid.listener.PhoneState)1