当前位置: 首页>>代码示例>>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;未经允许,请勿转载。