当前位置: 首页>>代码示例>>Java>>正文


Java TelephonyManager.CALL_STATE_IDLE属性代码示例

本文整理汇总了Java中android.telephony.TelephonyManager.CALL_STATE_IDLE属性的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.CALL_STATE_IDLE属性的具体用法?Java TelephonyManager.CALL_STATE_IDLE怎么用?Java TelephonyManager.CALL_STATE_IDLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.CALL_STATE_IDLE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d(TAG, "CALL_STATE_IDLE");
            if(mPlayerEngine != null && !mPlayerEngine.isPlaying() && !pauseFromUser) {
                mPlayerEngine.resume();
            }
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Log.d(TAG, "CALL_STATE_OFFHOOK");
        case TelephonyManager.CALL_STATE_RINGING:
            Log.d(TAG, "CALL_STATE_RINGING");
            if(mPlayerEngine != null && mPlayerEngine.isPlaying()) {
                mPlayerEngine.pause();
            }
            break;
    }
}
 
开发者ID:suifenge,项目名称:MusicPlayerEngine,代码行数:19,代码来源:AudioHelper.java

示例2: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber)
{
	switch (state)
	{
		case TelephonyManager.CALL_STATE_RINGING:
		case TelephonyManager.CALL_STATE_OFFHOOK:
			if (downloadService.getPlayerState() == PlayerState.STARTED && !downloadService.isJukeboxEnabled())
			{
				resumeAfterCall = true;
				downloadService.pause();
			}
			break;
		case TelephonyManager.CALL_STATE_IDLE:
			if (resumeAfterCall)
			{
				resumeAfterCall = false;
				downloadService.start();
			}
			break;
		default:
			break;
	}
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:24,代码来源:DownloadServiceLifecycleSupport.java

示例3: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);
    switch (state) {
        // 电话挂断
        case TelephonyManager.CALL_STATE_IDLE:
            resume();
            break;
        // 等待接电话
        case TelephonyManager.CALL_STATE_RINGING:
            pause();
            break;
        // 通话中
        case TelephonyManager.CALL_STATE_OFFHOOK:
            break;
        default:
            break;
    }
}
 
开发者ID:dueros,项目名称:dcs-sdk-java,代码行数:19,代码来源:AudioTrackPlayerImpl.java

示例4: onCallStateChanged

public void onCallStateChanged(String state) {
    Log.i(TAG, "onCallStateChanged, now state =" + state);

    stateEnum = PhoneCallStateEnum.IDLE;
    if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {
        phoneState = TelephonyManager.CALL_STATE_IDLE;
        stateEnum = PhoneCallStateEnum.IDLE;
    } else if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
        phoneState = TelephonyManager.CALL_STATE_RINGING;
        stateEnum = PhoneCallStateEnum.INCOMING_CALL;
    } else if (TelephonyManager.EXTRA_STATE_OFFHOOK.equals(state)) {
        int lastPhoneState = phoneState;
        phoneState = TelephonyManager.CALL_STATE_OFFHOOK;
        if (lastPhoneState == TelephonyManager.CALL_STATE_IDLE) {
            stateEnum = PhoneCallStateEnum.DIALING_OUT;
        } else if (lastPhoneState == TelephonyManager.CALL_STATE_RINGING) {
            stateEnum = PhoneCallStateEnum.DIALING_IN;
        }
    }

    handleLocalCall();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:22,代码来源:PhoneCallStateObserver.java

示例5: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
  Status afspilningsstatus = afspiller.getAfspillerstatus();
  Log.d("Opkaldshaandtering " + state + " afspilningsstatus=" + afspilningsstatus+" nummer="+incomingNumber);
  switch (state) {
    case TelephonyManager.CALL_STATE_OFFHOOK:
    case TelephonyManager.CALL_STATE_RINGING:
      Log.d("Opkald i gang");
      if (afspilningsstatus != Status.STOPPET) {
        venterPåKaldetAfsluttes = true;
        afspiller.pauseAfspilning();
      }
      break;
    case TelephonyManager.CALL_STATE_IDLE:
      Log.d("Idle state detected");
      if (venterPåKaldetAfsluttes) {
        try {
          afspiller.startAfspilning();
        } catch (Exception e) {
          Log.e(e);
        }
        venterPåKaldetAfsluttes = false;
      }
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:25,代码来源:Opkaldshaandtering.java

示例6: createAndStart

public synchronized static final LinphoneManager createAndStart(Context c) {
	if (instance != null)
		throw new RuntimeException("Linphone Manager is already initialized");

	instance = new LinphoneManager(c);
	instance.startLibLinphone(c);

	TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
	boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
	setGsmIdle(gsmIdle);

	return instance;
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:13,代码来源:LinphoneManager.java

示例7: callStateListener

/**
 * Handle PhoneState changes
 */
private void callStateListener() {
    // Get the telephony manager
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    //Starting listening for PhoneState changes
    phoneStateListener = new PhoneStateListener() {
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            switch (state) {
                //if at least one call exists or the phone is ringing
                //pause the MediaPlayer
                case TelephonyManager.CALL_STATE_OFFHOOK:
                case TelephonyManager.CALL_STATE_RINGING:
                    if (mediaPlayer != null) {
                        pauseMedia();
                        ongoingCall = true;
                    }
                    break;
                case TelephonyManager.CALL_STATE_IDLE:
                    // Phone idle. Start playing.
                    if (mediaPlayer != null) {
                        if (ongoingCall) {
                            ongoingCall = false;
                            resumeMedia();
                        }
                    }
                    break;
            }
        }
    };
    // Register the listener with the telephony manager
    // Listen for changes to the device call state.
    telephonyManager.listen(phoneStateListener,
            PhoneStateListener.LISTEN_CALL_STATE);
}
 
开发者ID:CommonsLab,项目名称:CommonsLab,代码行数:37,代码来源:MediaPlayerService.java

示例8: phoneCallStateUpdated

@Override
public void phoneCallStateUpdated(int state, String phoneNumber) {
    jsModule = this.reactContext.getJSModule(CallStateUpdateActionModule.class);

    switch (state) {
        //Hangup
        case TelephonyManager.CALL_STATE_IDLE:
            if(wasAppInRinging == true ) {
                if(wasAppInOffHook == true) {
                    jsModule.callStateUpdated("Disconnected", null);

                } else {
                    jsModule.callStateUpdated("Missed", null);
                }
            }
            wasAppInRinging = false;
            wasAppInOffHook = false;
            // Device call state: No activity.
            break;
        //Outgoing
        case TelephonyManager.CALL_STATE_OFFHOOK:
            //Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
            wasAppInOffHook = true;
            jsModule.callStateUpdated("Offhook", null);
            break;
        //Incoming
        case TelephonyManager.CALL_STATE_RINGING:
            // Device call state: Ringing. A new call arrived and is ringing or waiting. In the latter case, another call is already active.
            wasAppInRinging = true;
            jsModule.callStateUpdated("Incoming", phoneNumber);
            break;
    }
}
 
开发者ID:priteshrnandgaonkar,项目名称:react-native-call-detection,代码行数:33,代码来源:CallDetectionManagerModule.java

示例9: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    if (state == TelephonyManager.CALL_STATE_RINGING) {
        //Incoming call: Pause music
        pause();
    } else if (state == TelephonyManager.CALL_STATE_IDLE) {
        //Not in call: Play music
        play();
    } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
        //A call is dialing, active or on hold
    }
    super.onCallStateChanged(state, incomingNumber);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:13,代码来源:MusicService.java

示例10: isBusy

private boolean isBusy() {
  TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);

  return callState != CallState.STATE_IDLE || telephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:5,代码来源:WebRtcCallService.java

示例11: onCreate

@Override
public void onCreate() {
    audioStreamingManager = AudioStreamingManager.getInstance(AudioStreamingService.this);
    audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    NotificationManager.getInstance().addObserver(this, NotificationManager.audioProgressDidChanged);
    NotificationManager.getInstance().addObserver(this, NotificationManager.setAnyPendingIntent);
    NotificationManager.getInstance().addObserver(this, NotificationManager.audioPlayStateChanged);
    try {
        phoneStateListener = new PhoneStateListener() {
            @Override
            public void onCallStateChanged(int state, String incomingNumber) {
                if (state == TelephonyManager.CALL_STATE_RINGING) {
                    if (audioStreamingManager.isPlaying()) {
                        audioStreamingManager.handlePauseRequest();
                    }
                } else if (state == TelephonyManager.CALL_STATE_IDLE) {

                } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {

                }
                super.onCallStateChanged(state, incomingNumber);
            }
        };
        TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
        if (mgr != null) {
            mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
        }
    } catch (Exception e) {
        Log.e("tmessages", e.toString());
    }
    super.onCreate();
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:32,代码来源:AudioStreamingService.java

示例12: onCallStateChanged

@Override
public void onCallStateChanged(final int state, final String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    switch (state) {

        case TelephonyManager.CALL_STATE_OFFHOOK:
            if (DEBUG) {
                MyLog.i(CLS_NAME, "PhoneStateListener: TelephonyManager.CALL_STATE_OFFHOOK");
            }
            interrupt();
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            if (DEBUG) {
                MyLog.i(CLS_NAME, "PhoneStateListener: TelephonyManager.CALL_STATE_RINGING: " + incomingNumber);
            }
            interrupt();
            break;
        case TelephonyManager.CALL_STATE_IDLE:
            if (DEBUG) {
                MyLog.i(CLS_NAME, "PhoneStateListener: TelephonyManager.CALL_STATE_IDLE");
            }

            if (conditions.restartHotword()) {
                startHotwordDetection(conditions.getBundle());
            }

            conditions.removeInterrupted(params);
            break;
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:31,代码来源:SelfAware.java

示例13: onCallStateChanged

public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    if (state != TelephonyManager.CALL_STATE_IDLE) {
        mutePlayer();
    } else {
        unmutePlayer();
    }
}
 
开发者ID:R-a-dio,项目名称:R-a-dio-Amazing-Android-App,代码行数:9,代码来源:RadioService.java

示例14: getTelephoneCallState

public String getTelephoneCallState(Context context)
{
	try
	{
		int  currentState = TelephoneCallReceiver.getCurrentState();
		String telephoneCallState = "";
		
		switch (currentState)
	    {
	    	case TelephonyManager.CALL_STATE_IDLE:
	    		telephoneCallState = context.getString(R.string.monitoring_telephone_call_state_idle);
	    		break;
	    	
	    	case TelephonyManager.CALL_STATE_RINGING:
	    		telephoneCallState = context.getString(R.string.monitoring_telephone_call_state_ringing);
	    		break;
	    		
	    	case TelephonyManager.CALL_STATE_OFFHOOK:
	    		telephoneCallState = context.getString(R.string.monitoring_telephone_call_state_offhook);
	    		break;
	    }
		
		return telephoneCallState;
	}
	catch (Exception e)
       {
		return "";
       }
}
 
开发者ID:vassela,项目名称:AC2RD,代码行数:29,代码来源:MonitoringManager.java

示例15: CheckCalling

private boolean CheckCalling() {
    TelephonyManager telephonyService = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    return telephonyService == null || telephonyService.getCallState() == TelephonyManager.CALL_STATE_IDLE;
}
 
开发者ID:XFY9326,项目名称:EarPhoneKeySet,代码行数:4,代码来源:EarPhoneSetService.java


注:本文中的android.telephony.TelephonyManager.CALL_STATE_IDLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。