android电话服务
16lz
2021-12-10
Android打电话也是两行代码:
Intent intent = new Intent("android.intent.action.DIAL", Uri.parse("tel:10086") );
startActivity(intent);
这样便进进入呼叫界面了。
接下来我们再看一下监听电话状态的功能。
监听电话状态首先建立一个继承于PhoneStateListener电话监听类(如:TeleListener),并让TelephonyManager监听它。
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mTelephonyMgr.listen(new TeleListener(), PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTH);
TeleListener需要实现父类的几个方法,onCallStateChanged、onServiceStateChanged、onSignalStrengthChanged,根据方法名我们便可知其功能,这里就不再详述。
更多相关文章
- Android(安卓)去掉标题栏,状态栏,导航栏
- android 禁用或开启四大组件setComponentEnabledSetting
- Android(安卓)RIL源码分析(2)
- Android中判断网络连接是否可用及监控网络状态
- 代码实现android手机信号监听
- 使用saripaar对android输入控件进行快速验证
- android 来电自动接听和自动挂断
- android 来去电监听
- android shape 代码实现按钮背景