How can I answer a phone call and hang it up?

后端 未结 3 541
迷失自我
迷失自我 2020-12-18 10:42

I have code which is supposed to answer the phone and hang up right away when someone calls the phone. I get no errors and no force close when the call comes in from a diffe

3条回答
  •  北海茫月
    2020-12-18 11:14

    Add following code to AndroidManifest.xml

        
         (add it after READ_PHONE_STATE and before MODIFY_PHONE_STATE")
        
    

    and use it for EndCall :

    private void endCall() 
         { 
                Class c = TelephonyManager.class;  
                Method getITelephonyMethod = null;  
                try {  
    
                getITelephonyMethod = c.getDeclaredMethod("getITelephony",(Class[]) null);  
    
    
                getITelephonyMethod.setAccessible(true);  
                ITelephony iTelephony = (ITelephony) getITelephonyMethod.invoke(tm, (Object[]) null);  
                iTelephony.endCall();  
    
            } catch (Exception e) {  
    
            }   
     } 
    

提交回复
热议问题