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;
    	}
    }
    
  • 相关阅读:
    zipline自制data bundles
    zipline目录结构
    Zipline入门教程
    QuantStart量化交易文集
    如何学习量化投资
    数字货币量化分析报告[2018-02-07]
    用于金融分析的Python包
    时间序列模式——ARIMA模型
    一份数学小白也能读懂的「马尔可夫链蒙特卡洛方法」入门指南
    Python实现HMM(隐马尔可夫模型)
  • 原文地址:https://www.cnblogs.com/pandans/p/2773823.html
Copyright © 2011-2022 走看看