如何以编程方式断开 android 4.1.2 nexus 中的呼叫

2024-05-04

我能够以编程方式断开 Android 2.2 中未知号码来电的呼叫。但在 android 4.1 中,它不起作用。

在 android 2.2 中断开通话的工作代码:

private Class c;    
private  Method m;    
private com.android.internal.telephony.ITelephony telephonyService;    
public void onReceive(Context context, Intent intent)     
{    
   Bundle b = intent.getExtras();    
   String state = b.getString(TelephonyManager.EXTRA_STATE);    
   if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))   
   {    
     TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);    
     c = Class.forName(tm.getClass().getName());    
     m = c.getDeclaredMethod("getITelephony");    
     m.setAccessible(true);    
     telephonyService = (ITelephony) m.invoke(tm);    
     telephonyService.silenceRinger();   
     telephonyService.endCall();    
   }    
}

请帮助我。提前致谢

最后我得到了2.6版本的解决方案。

MODIFY_PHONE_STATE自 2.3+ 起,permission 不再适用于silenceRinger(),但endCall 就可以了。所以解决办法就是注释掉对silenceRinger()的调用。


自 2.3+ 起,MODIFY_PHONE_STATE 不再适用于silenceRinger(),但endCall 就可以了。

所以解决办法就是注释掉对silence Ringer()的调用。

一个简单的例子:

 http://androidbridge.blogspot.ro/2011/05/how-to-answer-incoming-call-in-android.html

Cheers

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何以编程方式断开 android 4.1.2 nexus 中的呼叫 的相关文章

随机推荐