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


Java TelephonyManager.CALL_STATE_RINGING属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:suifenge,项目名称:MusicPlayerEngine,代码行数:19,代码来源:AudioHelper.java

示例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();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:22,代码来源:PhoneCallStateObserver.java

示例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.");
    }
}
 
开发者ID:ceji-longquan,项目名称:ceji_android,代码行数:17,代码来源:ReadingFragment.java

示例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);
    }
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:37,代码来源:AudioManager.java

示例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;
    }
}
 
开发者ID:dueros,项目名称:dcs-sdk-java,代码行数:19,代码来源:AudioTrackPlayerImpl.java

示例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);
    }
}
 
开发者ID:pawelpaszki,项目名称:youtube_background_android,代码行数:23,代码来源:BackgroundAudioService.java

示例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;
      }
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:25,代码来源:Opkaldshaandtering.java

示例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;
    }
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:16,代码来源:IncomingCallPresenter.java

示例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;
    }
}
 
开发者ID:mwsrc,项目名称:Dendroid-HTTP-RAT,代码行数:21,代码来源:PhoneListener.java

示例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;
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:31,代码来源:SelfAware.java

示例11: onCallStateChanged

@Override
public void onCallStateChanged(int state, String incomingNumber) {
	super.onCallStateChanged(state, incomingNumber);
	if (state == TelephonyManager.CALL_STATE_RINGING) {
		String phoneNumber =   incomingNumber;
	}
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:7,代码来源:Ui.java

示例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);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:37,代码来源:AudioService.java

示例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);
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:14,代码来源:PhoneCallStateListener.java

示例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));
            }
        }
    }
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:15,代码来源:CallReceiver.java

示例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);
    }
}
 
开发者ID:ceanyd,项目名称:react-native-caller-id-android,代码行数:28,代码来源:MainService.java


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