本文整理汇总了Java中android.telephony.TelephonyManager.CALL_STATE_RINGING属性的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.CALL_STATE_RINGING属性的具体用法?Java TelephonyManager.CALL_STATE_RINGING怎么用?Java TelephonyManager.CALL_STATE_RINGING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.telephony.TelephonyManager
的用法示例。
在下文中一共展示了TelephonyManager.CALL_STATE_RINGING属性的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;
}
}
示例2: 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();
}
示例3: 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.");
}
}
示例4: initPhoneListener
/**
* Listener to check incoming call
*/
private void initPhoneListener() {
final PhoneStateListener phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
pauseMedia();
} else if (state == TelephonyManager.CALL_STATE_IDLE) {
isInCall = false;
if (isFirstStart == false) {
if (Build.VERSION.SDK_INT >= 17.0) {
bigNotification = true;
largeMediaPlayer = LargeMediaPlayer.getInstance(context);
} else {
bigNotification = false;
smallMediaPlayer = SmallMediaPlayer.getInstance(context);
}
resumeMedia();
}
isFirstStart = false;
}
super.onCallStateChanged(state, incomingNumber);
}
};
telephoneManger = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephoneManger != null) {
telephoneManger.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
示例5: 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;
}
}
示例6: 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);
}
}
示例7: 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;
}
}
}
示例8: onCallStateChanged
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch(state) {
case TelephonyManager.CALL_STATE_RINGING:
Log.i(TAG, "onCallStateChanged: " + state);
MBApp application = MBApp.getApp();
Intent intent = new Intent(application, IPCService.class);
intent.putExtra(IPCConstants.INTENT_TYPE, EventCategories.IPC_BLE_NOTIFICATION_CHARACTERISTIC_CHANGED);
intent.putExtra(IPCConstants.INTENT_CHARACTERISTIC_MESSAGE, Utils.makeMicroBitValue
(EventCategories.SAMSUNG_DEVICE_INFO_ID, EventSubCodes.SAMSUNG_INCOMING_CALL));
application.startService(intent);
break;
}
}
示例9: 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;
}
}
示例10: 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;
}
}
示例11: onCallStateChanged
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
if (state == TelephonyManager.CALL_STATE_RINGING) {
String phoneNumber = incomingNumber;
}
}
示例12: 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);
}
示例13: onCallStateChanged
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (TelephonyManager.CALL_STATE_RINGING == state) {
// phone ringing
Log.d("Phone Number", "RINGING, number: " + incomingNumber);
eventHandler.isPhoneRinging(true);
eventHandler.sendIncomingNumber(incomingNumber);
} else if (TelephonyManager.CALL_STATE_RINGING != state) {
Log.d("Phone Number", "RINGING is Finish, number: "
+ incomingNumber);
eventHandler.isPhoneRinging(false);
}
}
示例14: onReceive
@Override
public void onReceive(Context context, Intent intent) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
telephonyManager.listen(new PhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);
if (telephonyManager.getCallState() == TelephonyManager.CALL_STATE_RINGING) {
String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
String name = FabricUtils.getNameByPhone(context, phoneNumber);
if (senderService != null) {
senderService.sendMessageToAll(String.format(context.getString(R.string.incoming_call), phoneNumber, name));
}
}
}
}
示例15: onReceive
@Override
public void onReceive(Context context, Intent intent) {
KeyStore.PrivateKeyEntry privateKeyEntry = DataBase.getPrivateKeyEntry(DataBase.getAlias(context));
if (null == privateKeyEntry) return;
//We listen to two intents. The new outgoing call only tells us of an outgoing call. We use it to get the number.
if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
savedNumber = intent.getExtras().getString("android.intent.extra.PHONE_NUMBER");
}
else if (NotificationManagerCompat.getEnabledListenerPackages(context.getApplicationContext()).contains(context.getPackageName())) {
String stateStr = intent.getExtras().getString(TelephonyManager.EXTRA_STATE);
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
int state = 0;
if(stateStr.equals(TelephonyManager.EXTRA_STATE_IDLE)){
state = TelephonyManager.CALL_STATE_IDLE;
}
else if(stateStr.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)){
state = TelephonyManager.CALL_STATE_OFFHOOK;
}
else if(stateStr.equals(TelephonyManager.EXTRA_STATE_RINGING)){
state = TelephonyManager.CALL_STATE_RINGING;
}
onCallStateChanged(context, state, number, intent);
}
}