android获取电话的来电人和接听通话与结束
来源:互联网 发布:springmvc json 获取 编辑:程序博客网 时间:2024/04/30 08:20
CALL_ACTION 动作
package zking.com.android_21_phone;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.telephony.TelephonyManager;import android.util.Log;/** * Created by Administrator on 2017/7/11 0011. */public class MyPhoneState extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action.PHONE_STATE".equals(intent.getAction())){ //获取电话管理者 TelephonyManager tm= (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int state=tm.getCallState(); //获取电话号码 String number=intent.getStringExtra("incoming_number"); switch (state){ case TelephonyManager.CALL_STATE_RINGING: Log.i("test","有电话进来了"+number); break; case TelephonyManager.CALL_STATE_OFFHOOK: Log.i("test","通话中"+number); break; case TelephonyManager.CALL_STATE_IDLE: Log.i("test","通话结束了"+number); break; } } }}
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="zking.com.android_21_phone"> <!--读取电话状态的权限--> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name=".MyPhoneState"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE"></action> </intent-filter> </receiver> </application></manifest>
阅读全文
0 0
- android获取电话的来电人和接听通话与结束
- 电话来电,接听解读
- 来电、接听、挂断、拨打电话
- android 2.1 监听电话状态并自动接听来电
- android 2.1 监听电话状态并自动接听来电
- android 2.1 监听电话状态并自动接听来电
- android 2.1 监听电话状态并自动接听来电
- android 2.1 监听电话状态并自动接听来电
- Android 自动接听来电
- Android 自动接听来电
- Android 自动接听来电
- Android 来电自动接听
- 监听电话状态并自动接听来电
- Android:电话接听
- Android设定指定号码监听电话不弹拨号、通话界面,自动接听,关闭声音输出
- Android拒绝来电的实现--ITelephony类的反射(结束电话)
- android 拨号盘输入号码时来电,通话结束后回到拨号盘,如何保存之前输入的号码
- android来电话按返回键结束来电实现
- java 将A对象的值copy到B对象(根据属性名设置属性值)
- [BZOJ3146][AHOI2009]维护序列seq
- A
- jquery中$each()方法使用
- x86和x64
- android获取电话的来电人和接听通话与结束
- hystrix熔断 学习笔记(一)
- 【数据结构与算法】二叉树递归与非递归遍历(附完整源码)
- 【算法】排序算法第一讲:插入排序
- Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes
- 《笑傲股市 How to Make Money in Stocks》读书笔记
- switch-case选择结构
- win10+python3.5+pycharm5.0+CPU 安装tensorflow
- NGUI学习