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;
    	}
    }
    
  • 相关阅读:
    转:关于C++ const 的全面总结
    HDOJ->考新郎(sdut1021)
    有些人笑着,其实心里哭的很疼
    HDU-2084 数塔
    SDUT2176 -> 递归的函数
    删数问题(SDUT2072 )
    微信2种access_token对比
    nginx配置C compiler cc is not found
    ftp无法连接的原因
    php的ftp类
  • 原文地址:https://www.cnblogs.com/pandans/p/2773823.html
Copyright © 2011-2022 走看看