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


Java TelephonyManager.getCallState方法代码示例

本文整理汇总了Java中android.telephony.TelephonyManager.getCallState方法的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.getCallState方法的具体用法?Java TelephonyManager.getCallState怎么用?Java TelephonyManager.getCallState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.getCallState方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码行数:16,代码来源: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,代码行数:25,代码来源: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,代码行数:14,代码来源: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,代码行数:6,代码来源: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,代码行数:32,代码来源: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,代码行数:16,代码来源: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,代码行数:10,代码来源: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,代码行数:5,代码来源: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,代码行数:6,代码来源:LockScreenManager.java


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