本文介绍了如何以编程方式断开的安卓4.1.2关系通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够以编程方式断开呼叫在Android 2.2的来电数目不详的电话。但在Android的4.1,它不工作。

i am able to disconnect the call programmatically for incoming unknown number call in android 2.2. But in android 4.1, its not working.

工作code断开呼叫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();
   }
}

请帮忙me.Thanks提前

Please help me.Thanks in advance

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

MODIFY_PHONE_STATE 许可,不再从事silenceRinger(),因为2.3+,但按结束就好了。所以,解决的办法是注释掉调用silenceRinger()。

MODIFY_PHONE_STATE permission is no longer working on silenceRinger() since 2.3+, but endCall is just fine. So the solution is to comment out the call to silenceRinger().

推荐答案

MODIFY_PHONE_STATE不再工作silenceRinger(),因为2.3+,但按结束就好了。

MODIFY_PHONE_STATE is no longer working on silenceRinger() since 2.3+, but endCall is just fine.

所以,解决的办法是注释掉调用silenceRinger()。

So the solution is to comment out the call to silenceRinger().

和一个简单的例子:

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

干杯

这篇关于如何以编程方式断开的安卓4.1.2关系通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 10:45