Example usage for android.telephony PhoneStateListener LISTEN_NONE

List of usage examples for android.telephony PhoneStateListener LISTEN_NONE

Introduction

In this page you can find the example usage for android.telephony PhoneStateListener LISTEN_NONE.

Prototype

int LISTEN_NONE

To view the source code for android.telephony PhoneStateListener LISTEN_NONE.

Click Source Link

Document

Stop listening for updates.

Usage

From source file:fr.inria.ucn.listeners.MyPhoneStateListener.java

/**
 * //  www .  j a  va 2  s .  c o m
 * @param c
 */
public void disable(Context c) {
    TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
    if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) {
        tm.listen(this, PhoneStateListener.LISTEN_NONE);
        this.c = null;
    } // else no telephony
}

From source file:ro.ui.pttdroid.Player.java

@Override
public void onDestroy() {
    playerThread.shutdown();
    telephonyManager.listen(phoneCallListener, PhoneStateListener.LISTEN_NONE);
}

From source file:es.warp.desktop_droid.TelephonyEventService.java

@Override
public void onDestroy() {
    Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG);
    Log.d("TelephonyEventService", "onDestroy");
    TelephonyManager manager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    manager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}

From source file:de.inhji.cordova.plugin.Telephony.java

public void onDestroy() {
    super.onDestroy();
    Log.i(TAG, "Stopping PhoneStateListener..");
    tm.listen(listener, PhoneStateListener.LISTEN_NONE);
}

From source file:ru.dublgis.androidhelpers.mobility.CellListener.java

public synchronized boolean start() {
    Log.d(TAG, "start");
    try {/*  www  .  j a v  a2s. c om*/
        if (mManager == null) {
            mManager = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
        }

        Runnable listenRunnable = new Runnable() {
            @Override
            public void run() {
                if (mManager != null) {
                    try {
                        Looper.prepare();
                        mListenerLooper = Looper.myLooper();
                        mListener = new CellListenerImpl();
                        mManager.listen(mListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
                        Looper.loop();
                        mManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
                    } catch (Throwable ex) {
                        Log.e(TAG, "Failed to start TelephonyManager listener", ex);
                    }
                }
            }
        };

        mListenerThread = new Thread(listenRunnable, "Listen TelephonyManager");
        mListenerThread.start();
        return true;
    } catch (Throwable e) {
        Log.e(TAG, "Exception while starting cell listener: ", e);
        return false;
    }
}

From source file:ru.dublgis.androidhelpers.mobility.CellListener.java

public synchronized void stop() {
    Log.d(TAG, "stop");

    try {//  www . ja  v  a2s  .c o m
        if (mManager != null) {
            mManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
        }
    } catch (SecurityException ex) {
        Log.e(TAG, "Failed to stop listener", ex);
    }

    if (null != mListenerLooper) {
        mListenerLooper.quit();
    }

    try {
        if (mListenerThread.isAlive()) {
            mListenerThread.join(300);
        }
    } catch (InterruptedException e) {
        Log.e(TAG, "Exception in cppDestroyed: ", e);
    }
}

From source file:de.mangelow.throughput.NotificationService.java

@Override
public void onDestroy() {
    if (D)/*  w ww  .  j av a2  s .com*/
        Log.d(TAG, "Service stopped");

    if (tmanager != null) {
        tmanager.listen(new MyPhoneStateListener(), PhoneStateListener.LISTEN_NONE);
        tmanager = null;
    }

    if (handler != null)
        handler = null;
    if (mBroadcastReceiver != null) {
        unregisterReceiver(mBroadcastReceiver);
        mBroadcastReceiver = null;
    }
    removeNotification();

}

From source file:org.wso2.iot.agent.services.NetworkInfoService.java

@Override
public void onDestroy() {
    telephonyManager.listen(deviceNetworkStatusListener, PhoneStateListener.LISTEN_NONE);
    if (Constants.WIFI_SCANNING_ENABLED) {
        unregisterReceiver(wifiScanReceiver);
    }// w  w w  . j  a  v  a2 s  .c om
    thisInstance = null;
    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "Service destroyed.");
    }
}

From source file:uk.ac.horizon.ubihelper.service.channel.CellStrengthChannel.java

@Override
protected void handleStop() {
    if (telephony != null)
        telephony.listen(listener, PhoneStateListener.LISTEN_NONE);
}

From source file:ru.org.sevn.audiobookplayer.AppService.java

@Override
public void onDestroy() {
    super.onDestroy();

    TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    if (mgr != null) {
        mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
    }//  w w  w . jav a 2 s .  c o m

    saveLastOpened(preferenceEditor);
    releaseMediaPlayer();
    audioManager.abandonAudioFocus(this);
    if (preferenceEditor != null) {
        preferenceEditor.commit();
        preferenceEditor = null;
    }
    stopForeground(true);
}