2010年高考英语试题及答案(全国卷2)

考试。。

1.

new Thread() {

public void run() {

Instrumentation inst = new Instrumentation();

inst.sendKeyDownUpSync(KeyEvent.KEYCODE_ENTER);

};

}.start();

Instrumentation 这个类是在Android 单元测试的时候生成各种事件的时候使用到的类,通过该类我们可以发出各种按键及其它事件。

需要注意的是发出的事件必须在新的线程中产生

2.需要使用反射机制将ITelephony反射出来进行操作。

private void dial(String number) {

Class<TelephonyManager> c = TelephonyManager.class;

Method getITelephonyMethod = null;

try {

getITelephonyMethod = c.getDeclaredMethod("getITelephony",

(Class[]) null);

getITelephonyMethod.setAccessible(true);

} catch (SecurityException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (NoSuchMethodException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

try {

TelephonyManager tManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Object iTelephony;

iTelephony = (Object) getITelephonyMethod.invoke(tManager,(Object[]) null);

Method dial = iTelephony.getClass().getDeclaredMethod("dial", String.class);

dial.invoke(iTelephony, number);

} catch (IllegalArgumentException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IllegalAccessException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SecurityException e) {

// TODO Auto-generated catch block

e.printStackTrace();

你可能喜欢

  • 高考英语试题全国卷
  • 重要的地理经纬线
  • 教师招聘面试问题
  • 北京高考英语试题及答案

2010年高考英语试题及答案(全国卷2)相关文档

最新文档

返回顶部