zoukankan      html  css  js  c++  java
  • 不弹出拨号盘发送字符

    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    
    class Dtmf {
    	private static final String CALL_MANAGER = "com.android.internal.telephony.CallManager";
    	private static final String SEND_DTMF = "sendDtmf";
    	private static final String GET_INSTANCE = "getInstance";
    	private Method mSendDtmfMethod;
    	private Object mCallManager;
    
    	public Dtmf() {
    		try {
    			Class<?> callManagerClass = Class.forName(CALL_MANAGER); // Obtain
    																		// an
    																		// instance
    																		// of
    																		// CallManager
    			Method getInstanceMethod = callManagerClass.getMethod(GET_INSTANCE);
    			mCallManager = getInstanceMethod.invoke(null);
    			// Get sendDtmf(char)
    			Class<?>[] sendDtmfParamTypes = new Class<?>[] { char.class };
    			mSendDtmfMethod = callManagerClass.getMethod(SEND_DTMF, sendDtmfParamTypes);
    		} catch (ClassNotFoundException e) {
    		} catch (NoSuchMethodException e) {
    		} catch (IllegalArgumentException e) {
    		} catch (IllegalAccessException e) {
    		} catch (InvocationTargetException e) {
    		}
    	}
    
    	public boolean sendDtmf(char ch) {
    		boolean result = false;
    		if (mCallManager != null && mSendDtmfMethod != null) {
    			try {
    				Object res = mSendDtmfMethod.invoke(mCallManager, new Object[] { Character.valueOf(ch) });
    				if (res instanceof Boolean) {
    					result = ((Boolean) res).booleanValue();
    				}
    			} catch (IllegalArgumentException e) {
    			} catch (IllegalAccessException e) {
    			} catch (InvocationTargetException e) {
    			}
    		}
    		return result;
    	}
    }
    
  • 相关阅读:
    IIs6基础上发布WebApi注意事项
    VS2010下开发WebApi 基本步骤
    C# 两个datatable中的数据快速比较返回交集或差集
    myeclipse快捷键使用
    Java中时间
    数组排序后插入
    所有的jsp页面都放到WEB-INF目录
    jsp内置对象浅谈
    JSP九大内置对象的作用和用法总结?
    JSP九大内置对象及四个作用域
  • 原文地址:https://www.cnblogs.com/pandans/p/2773823.html
Copyright © 2011-2022 走看看