Android調用ITelephony類的endCall()方法

來源:互聯網
上載者:User

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

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();
}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.