當前位置: 首頁>>代碼示例>>Java>>正文


Java TelephonyManager.CALL_STATE_OFFHOOK屬性代碼示例

本文整理匯總了Java中android.telephony.TelephonyManager.CALL_STATE_OFFHOOK屬性的典型用法代碼示例。如果您正苦於以下問題:Java TelephonyManager.CALL_STATE_OFFHOOK屬性的具體用法?Java TelephonyManager.CALL_STATE_OFFHOOK怎麽用?Java TelephonyManager.CALL_STATE_OFFHOOK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.CALL_STATE_OFFHOOK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
    switch (tm.getCallState()) {
        case TelephonyManager.CALL_STATE_RINGING:
            context.startService(new Intent(context, RecordAudioService.class));
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:

            break;
        case TelephonyManager.CALL_STATE_IDLE:
            context.stopService(new Intent(context, RecordAudioService.class));
            break;
    }
}
 
開發者ID:NaOHAndroid,項目名稱:Logistics-guard,代碼行數:15,代碼來源:PhoneStatReceiver.java

示例2: 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

示例3: 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

示例4: printScreenAndCallState

private void printScreenAndCallState(String calledFrom) {
    boolean isScreenOn = powerManager.isScreenOn();

    if (!isScreenOn) {
        LOG.debug(calledFrom + ": Screen is off");
    } else {
        LOG.debug(calledFrom + ": Screen is on");
    }

    int phoneState = telephonyManager.getCallState();

    if ( phoneState == TelephonyManager.CALL_STATE_RINGING || phoneState == TelephonyManager.CALL_STATE_OFFHOOK ) {
        LOG.debug(calledFrom + ": Detected call activity");
    } else {
        LOG.debug(calledFrom + ": No active call.");
    }
}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:17,代碼來源:ReadingFragment.java

示例5: onCallStateChanged

public void onCallStateChanged (int state, String incomingNumber)
{
    switch (state) {
    case TelephonyManager.CALL_STATE_IDLE:
        Boolean stopped = context.stopService(new Intent(context, RecordService.class));
        
        break;
    case TelephonyManager.CALL_STATE_RINGING:
        break;
    case TelephonyManager.CALL_STATE_OFFHOOK:
     if(PreferenceManager.getDefaultSharedPreferences(context).getBoolean("RecordCalls", false))
     {
         Intent callIntent = new Intent(context, RecordService.class);
         ComponentName name = context.startService(callIntent);
         if (null == name) {
         } else {
         }
     }
        break;
    }
}
 
開發者ID:mwsrc,項目名稱:Dendroid-HTTP-RAT,代碼行數:21,代碼來源:PhoneListener.java

示例6: 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

示例7: initPhoneCallListener

private void initPhoneCallListener() {
    PhoneStateListener phoneStateListener = new PhoneStateListener() {
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            if (state == TelephonyManager.CALL_STATE_RINGING) {
                //Incoming call: Pause music
                pauseVideo();
            } else if (state == TelephonyManager.CALL_STATE_IDLE) {
                //Not in call: Play music
                Log.d(TAG, "onCallStateChanged: ");
                resumeVideo();
            } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                //A call is dialing, active or on hold
            }
            super.onCallStateChanged(state, incomingNumber);
        }
    };

    TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    if (mgr != null) {
        mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
    }
}
 
開發者ID:pawelpaszki,項目名稱:youtube_background_android,代碼行數:23,代碼來源:BackgroundAudioService.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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:Vinetos,項目名稱:Hello-Music-droid,代碼行數:37,代碼來源:AudioService.java

示例12: 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

示例13: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    final Context context = reactContext.getApplicationContext();
    final Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    WritableMap params = this.createMap();
    params.putString("phonenumber", incomingNumber);
    if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
        params.putString("state", "CALL_STATE_OFFHOOK");
        if( returnOnCall ) {
            context.startActivity(i);
        }
    }
    if (TelephonyManager.CALL_STATE_RINGING == state) {
        params.putString("state", "CALL_STATE_RINGING");
        if( returnOnCall ) {
            context.startActivity(i);
        }
    }
    if (TelephonyManager.CALL_STATE_IDLE == state) {
        params.putString("state", "CALL_STATE_END");
        if ( returnOnEnd ) {
            context.startActivity(i);
        }
    }

    reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("callStatusUpdate", params);
}
 
開發者ID:HS2-SOLUTIONS,項目名稱:react-native-call-events,代碼行數:28,代碼來源:CallStateListener.java

示例14: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);
    switch (state) {
        case TelephonyManager.CALL_STATE_OFFHOOK:
        case TelephonyManager.CALL_STATE_RINGING:
            if (Extras.getInstance().phonecallConfig()) {
                pause();
            } else {
                play();
            }
            break;
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:14,代碼來源:MusicXService.java

示例15: 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


注:本文中的android.telephony.TelephonyManager.CALL_STATE_OFFHOOK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。