alien
alien
  • 发布:2015-06-20 00:24
  • 更新:2016-11-08 15:24
  • 阅读:2350

请问怎么监听来电呼出呼入或者短信发出发入?

分类:HTML5+

如题,我希望做一个来电的识别。安卓的代码如下:
package com.zhouzijing.android.demo;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.util.Log;

public class BroadcastReceiverMgr extends BroadcastReceiver {

private final String TAG = MyBroadcastReceiver.TAG;  

@Override  
public void onReceive(Context context, Intent intent) {  
    String action = intent.getAction();  
    Log.i(TAG, "[Broadcast]"+action);  

    //呼入电话  
    if(action.equals(MyBroadcastReceiver.B_PHONE_STATE)){  
        Log.i(TAG, "[Broadcast]PHONE_STATE");  
        doReceivePhone(context,intent);  
    }  
}  

/**  
 * 处理电话广播.  
 * @param context  
 * @param intent  
 */  
public void doReceivePhone(Context context, Intent intent) {  
    String phoneNumber = intent.getStringExtra(  

TelephonyManager.EXTRA_INCOMING_NUMBER);
TelephonyManager telephony =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
int state = telephony.getCallState();
switch(state){
case TelephonyManager.CALL_STATE_RINGING:
Log.i(TAG, "[Broadcast]等待接电话="+phoneNumber);
break;
case TelephonyManager.CALL_STATE_IDLE:
Log.i(TAG, "[Broadcast]电话挂断="+phoneNumber);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.i(TAG, "[Broadcast]通话中="+phoneNumber);
break;
}
}
}

2015-06-20 00:24 负责人:无 分享
已邀请:
Hao2016

Hao2016

这是java的代码吧?
h5的怎么获取来电呢?

liugm

liugm

您这个功能实现了吗

码农_1224

码农_1224

你好,你这个功能实现了吗?

NewsNing

NewsNing - 天行键

http://ask.dcloud.net.cn/article/1006

该问题目前已经被锁定, 无法添加新回复