當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。