本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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.");
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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;
}
}
}
示例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 "";
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
}
示例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);
}