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


Java方法android.telephony.TelephonyManager.getCallState代码示例

以下是Java方法android.telephony.TelephonyManager.getCallState的代码示例。如果您正苦于以下问题:Java TelephonyManager.getCallState方法的具体用法?Java TelephonyManager.getCallState怎么用?Java TelephonyManager.getCallState使用的例子?那么恭喜您, 这里整理的方法代码示例例程将为您提供帮助。您也可以进一步了解该方法所在android.telephony.TelephonyManager的用法示例。

本文一共展示了TelephonyManager.getCallState的9个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onReceive

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@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,完整代码来源:PhoneStatReceiver.java


示例2: getCallState

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
/**
 * 获取电话状态
 * 
 * @return String
 */
public static String getCallState(Context context)
{
    TelephonyManager mTm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    if (mTm != null)
    {
        switch (mTm.getCallState())
        {
            case android.telephony.TelephonyManager.CALL_STATE_IDLE:
                return "电话状态[CallState]: 无活动";
            case android.telephony.TelephonyManager.CALL_STATE_OFFHOOK:
                return "电话状态[CallState]: 无活动";
            case android.telephony.TelephonyManager.CALL_STATE_RINGING:
                return "电话状态[CallState]: 无活动";
            default:
                return "电话状态[CallState]: 未知";
        }
    }
    return "";
}
 
开发者ID:zhuyu1022,项目:amap,完整代码来源:MIP_DeviceInfoUtils.java


示例3: createAndStart

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public synchronized static final LinphoneManager createAndStart(Context c) {
	if (instance != null)
		throw new RuntimeException("Linphone Manager is already initialized");

	instance = new LinphoneManager(c);
	instance.startLibLinphone(c);

	TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
	boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
	setGsmIdle(gsmIdle);

	return instance;
}
 
开发者ID:treasure-lau,项目:Linphone4Android,完整代码来源:LinphoneManager.java


示例4: isBusy

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private boolean isBusy() {
  TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);

  return callState != CallState.STATE_IDLE || telephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE;
}
 
开发者ID:XecureIT,项目:PeSanKita-android,完整代码来源:WebRtcCallService.java


示例5: onReceive

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@Override
public synchronized void onReceive(Context context, Intent intent) {
    if (intent == null || intent.getAction() == null || !ACTION.equals(intent.getAction()))
        return;

    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    int phoneState = manager.getCallState();
    if (phoneState != TelephonyManager.CALL_STATE_IDLE) {
        return;
    }
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    boolean isCallingOn = pref.getBoolean("calling_on", false);
    if (isCallingOn == true) {
        return;
    }
    if (pref.getBoolean("volume_key_lock", false) == true) {
        mContext = context;
        Utils.setMusicKey(mContext);
        for (int i = 0; i < interval.length; i++) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    Utils.setMusicKey(mContext);
                }
            }, interval[i]);
        }
        if (!Utils.checkAccessibilityPermission(context)) {
            Utils.showSmallToast(context, context.getString(R.string.toast_alert_enable_volkey_without_accessibility), Toast.LENGTH_LONG);
        }
    }
}
 
开发者ID:KrongKrongPadakPadak,项目:mvo,完整代码来源:VolumeChangeReceiver.java


示例6: onReceive

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
@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,完整代码来源:CallReceiver.java


示例7: isIncomingCall

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private static boolean isIncomingCall() {
    try {
        TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        return (phone.getCallState() == TelephonyManager.CALL_STATE_RINGING);
    } catch (Throwable t) {
        XposedBridge.log(t);
        return false;
    }
}
 
开发者ID:WrBug,项目:GravityBox,完整代码来源:ModPower.java


示例8: CheckCalling

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
private boolean CheckCalling() {
    TelephonyManager telephonyService = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    return telephonyService == null || telephonyService.getCallState() == TelephonyManager.CALL_STATE_IDLE;
}
 
开发者ID:XFY9326,项目:EarPhoneKeySet,完整代码来源:EarPhoneSetService.java


示例9: isOnPhoneCall

import android.telephony.TelephonyManager; //导入方法依赖的package包/类
public boolean isOnPhoneCall() {
    TelephonyManager telephonyManager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
    Log.d(TAG, "isOnPhoneCall: call state = " + telephonyManager.getCallState());
    return telephonyManager.getCallState() != 0;
}
 
开发者ID:bunnyblue,项目:NoticeDog,完整代码来源:LockScreenManager.java



注:本文示例均筛选自Github等开源项目,代码版权请参考对应项目的License;未经允许,请勿转载。