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;
    	}
    }
    
  • 相关阅读:
    全文搜索 Contains 与like 的区别
    Easyui _treegrid 动态加载子节点
    十五、ES开启SSL访问
    十二、ES分词器
    十一、ES监控
    十六、源码部署EFK之快乐没有了
    十四、ES开启密码认证
    十三、ES备份恢复
    十七、优化ES
    正则表达式
  • 原文地址:https://www.cnblogs.com/pandans/p/2773823.html
Copyright © 2011-2022 走看看