Java Code Examples for android.telephony.PhoneStateListener#LISTEN_SIGNAL_STRENGTHS

The following examples show how to use android.telephony.PhoneStateListener#LISTEN_SIGNAL_STRENGTHS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidSignalStrength.java    From QtAndroidTools with MIT License 5 votes vote down vote up
public void appStateChanged(int newState)
{
    final TelephonyManager TelephonyMngr = (TelephonyManager)mActivityInstance.getSystemService(Context.TELEPHONY_SERVICE);
    final SignalStateListener Listener = mSignalStateListener;
    int ListenEvent = PhoneStateListener.LISTEN_NONE;

    switch(newState)
    {
        case APP_STATE_CREATE:
        case APP_STATE_START:
            ListenEvent = PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;
            break;
        case APP_STATE_STOP:
        case APP_STATE_DESTROY:
            ListenEvent = PhoneStateListener.LISTEN_NONE;
            break;
    }

    final int Event = ListenEvent;
    mActivityInstance.runOnUiThread(new Runnable()
    {
        @Override
        public void run()
        {
            TelephonyMngr.listen(Listener, Event);
        }
    });
}
 
Example 2
Source File: InformationCollector.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
/** Returns mobile data network connection type. */
/*
 * private int getTelephonyNetworkType() { //assert
 * NETWORK_TYPES[14].compareTo("EHRPD") == 0;
 * 
 * int networkType = telManager.getNetworkType(); if (networkType <
 * NETWORK_TYPES.length) {
 * 
 * } else { return 0; } }
 */

// Listeners
private void registerListeners()
{
    initNetwork();
    
    if (telListener == null)
    {
        telListener = new TelephonyStateListener();
        
        int events = PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;
        
        if (haveCourseLocationPerm)
            events |= PhoneStateListener.LISTEN_CELL_LOCATION;
            
        telManager.listen(telListener, events);
    }
}