挂断电话

来源:互联网 发布:三星盖乐世3淘宝 编辑:程序博客网 时间:2024/05/06 04:51

1. 在src下新建一个包:com.android.internal.telephony(和ITelephony.aidl 中 package 声明的包名一样);
2. 然后从系统源码中把ITelephony.aidl文件拷贝到 com.android.internal.telephony包下。(也可以先新建一个ITelephony.aidl, 然后再把内容拷贝进去(ITelephony.aidl文件内容可以在http://www.netmite.com/android/mydroid/1.5/frameworks/base/telephony/java/com/android/internal/telephony/ITelephony.aidl 找到,这个方法适合没有SDK源码文件的开发者));
3. 在src下新建一个包:android.telephony, 然后新建一个NeighboringCellInfo.aidl,其内容为:
package android.telephony;

 

parcelable NeighboringCellInfo;

4.从私有方法中获取ITelephony: 代码如下。

tManager = (TelephonyManager)
this.getSystemService(Context.TELEPHONY_SERVICE);
//初始化iTelephony
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 {
iTelephony = (ITelephony) getITelephonyMethod.invoke(tManager, (Object[])null);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

 

转自:::http://topic.csdn.net/u/20091226/00/09e2979b-7c8c-4991-856d-586a278875c0.html