本文整理汇总了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;
}
}
示例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 "";
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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));
}
}
}
}
示例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;
}
}
示例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;
}
示例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;
}