<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-348  評論-598  文章-0  trackbacks-0
    需要使用反射機制將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();
            } 
    catch (NoSuchMethodException e) {
                
    // TODO Auto-generated catch block
                e.printStackTrace();
            } 
    catch (InvocationTargetException e) {
                
    // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
        
    private void call(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("call", 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();
            } 
    catch (NoSuchMethodException e) {
                
    // TODO Auto-generated catch block
                e.printStackTrace();
            } 
    catch (InvocationTargetException e) {
                
    // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }


    ---------------------------------------------------------
    專注移動開發

    Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
    posted on 2011-01-25 14:38 TiGERTiAN 閱讀(10019) 評論(6)  編輯  收藏 所屬分類: Android

    評論:
    # re: Android彈出撥號界面和撥打電話實現 2012-04-04 11:12 | hello1719
    您好啊,我想問一下,為什么我用這段代碼的時候,有兩句報錯呢?如下所示

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


    報錯內容是:Unhandled exception type InvocationTargetException

    您順便能把ITelephony.aidl 文件內容發一下嗎?是不是我少添加了什么內容呢?  回復  更多評論
      
    # re: Android彈出撥號界面和撥打電話實現 2012-04-04 18:23 | TiGERTiAN
    @hello1719
    跟AIDL沒啥關系吧,就是直接反射內部類的內部方法  回復  更多評論
      
    # re: Android彈出撥號界面和撥打電話實現 2012-04-06 10:19 | hello1719
    @TiGERTiAN
    嗯已經解決了。。
      回復  更多評論
      
    # re: Android彈出撥號界面和撥打電話實現 2013-01-08 09:25 | xiaotang_hb
    請問樓主,這里能改變,撥號界面和撥打界面嗎?顯示我的自定義界面UI?請教下,給我點思路。謝謝  回復  更多評論
      
    # re: Android彈出撥號界面和撥打電話實現 2016-03-08 16:45 | jaime
    請我dial和call方法有什么區別么?   回復  更多評論
      
    # re: Android彈出撥號界面和撥打電話實現 2016-03-09 10:44 | firetomato
    這找不到call是怎么回事?現在有別的方法實現這個功能嗎?  回復  更多評論
      
    主站蜘蛛池模板: 最新仑乱免费视频| 国内永久免费crm系统z在线| 亚洲欧美黑人猛交群| 国产婷婷综合丁香亚洲欧洲| 久久精品私人影院免费看| 国产一级婬片A视频免费观看| 一级毛片免费全部播放| jizz免费在线观看| 一区二区在线免费视频| 国产免费牲交视频免费播放| 中文字幕在线成人免费看| 国产一级一毛免费黄片| 免费无码又爽又刺激高潮视频| 久久精品一区二区免费看| 三年片在线观看免费观看大全一| 97在线视频免费公开观看| 亚洲香蕉免费有线视频| 黄页网站免费在线观看| 大地资源二在线观看免费高清| 国内大片在线免费看| 四虎免费永久在线播放| 久久久久亚洲AV成人网| 国产精品亚洲а∨无码播放| 亚洲人成网址在线观看| 亚洲人成日本在线观看| 亚洲AV一区二区三区四区| 黄网站色成年片大免费高清 | 久久久久亚洲精品天堂久久久久久 | 九九综合VA免费看| 中文字幕在线免费看线人| 热re99久久6国产精品免费| 亚洲第一网站免费视频| 午夜色a大片在线观看免费| 亚洲国产精品嫩草影院久久| 97在线视频免费| 两个人的视频高清在线观看免费 | 久久免费精品视频| 日韩在线免费视频| 国产婷婷高清在线观看免费| 最新精品亚洲成a人在线观看| 久久精品国产亚洲精品2020|