1.首先创建变量
private TelephonyManager mTelephonyManager;
private String mString = "";
2、
//判断sim卡的状态
public void Checksimcard() {
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = mTelephonyManager.getSimState();
switch (simState) {
case TelephonyManager.SIM_STATE_ABSENT:
mString = "无卡";
break;
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
mString = "需要NetworkPIN解锁";
break;
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
mString = "需要PIN解锁";
break;
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
mString = "需要PUN解锁";
break;
case TelephonyManager.SIM_STATE_READY:
mString = "良好";
break;
case TelephonyManager.SIM_STATE_UNKNOWN:
mString = "未知状态";
break;
}
}
3、
// 系统的打电话
Intent intent = new Intent(Intent.ACTION_CALL,
Uri.parse("tel:" + telephonnum));
startActivity(intent);
4、调用系统的拨号盘
// 系统的打电话
Intent telephonedial = new Intent(Intent.ACTION_CALL_BUTTON);
startActivity(telephonedial);
5.添加权限
<!-- 拨打电话的权限 -->
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
本文介绍如何使用Android应用程序检测SIM卡状态,并通过拨打电话功能实现与系统的交互。主要内容包括SIM卡状态的判断、拨打电话操作以及必要的权限申请。
1116

被折叠的 条评论
为什么被折叠?



